python-feedgen/tests/test_main.py
Lars Kiesow 3371c2882f
Use Unittest Asserts
This patch switches to the assert statements provided by Python's unit
test framework to assure the statements are always executed and produce
proper error messages in case of test failures.
2020-01-29 00:10:33 +01:00

37 lines
913 B
Python

# -*- coding: utf-8 -*-
'''
Tests for feedgen main
'''
import os
import sys
import tempfile
import unittest
from feedgen import __main__
class TestSequenceFunctions(unittest.TestCase):
def test_usage(self):
sys.argv = ['feedgen']
with self.assertRaises(SystemExit) as e:
__main__.main()
self.assertEqual(e.exception.code, None)
def test_feed(self):
for ftype in 'rss', 'atom', 'podcast', 'torrent', 'dc.rss', 'dc.atom',\
'syndication.rss', 'syndication.atom':
sys.argv = ['feedgen', ftype]
__main__.main()
def test_file(self):
for extemsion in '.atom', '.rss':
fh, filename = tempfile.mkstemp(extemsion)
sys.argv = ['feedgen', filename]
try:
__main__.main()
finally:
os.close(fh)
os.remove(filename)