Unit tests - version.t now uses BaseTestCase
This commit is contained in:
committed by
Paul Beckingham
parent
74bca0e5bf
commit
3c28566590
@@ -31,37 +31,35 @@ import os
|
|||||||
# Ensure python finds the local simpletap module
|
# Ensure python finds the local simpletap module
|
||||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
import unittest
|
from basetest import BaseTestCase
|
||||||
|
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
class TestVersion(unittest.TestCase):
|
class TestVersion(BaseTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def prepare(cls):
|
||||||
"""Executed once before any test in the class"""
|
|
||||||
# Empty rc file
|
# Empty rc file
|
||||||
open("version.rc", 'w').close()
|
open("version.rc", 'w').close()
|
||||||
|
|
||||||
def testVersion(self):
|
def testVersion(self):
|
||||||
"""Copyright is current"""
|
"""Copyright is current"""
|
||||||
command = ["../src/task", "rc:version.rc", "version"]
|
args = ["rc:version.rc", "version"]
|
||||||
|
|
||||||
# Merge STDOUT and STDERR
|
code, out, err = self.callTaskSuccess(args)
|
||||||
p = Popen(command, stdout=PIPE, stderr=STDOUT)
|
|
||||||
out, err = p.communicate()
|
|
||||||
|
|
||||||
expected = "Copyright \(C\) \d{4} - %d" % (datetime.now().year,)
|
expected = "Copyright \(C\) \d{4} - %d" % (datetime.now().year,)
|
||||||
self.assertRegexpMatches(out.decode("utf8"), expected)
|
self.assertRegexpMatches(out.decode("utf8"), expected)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def finish(cls):
|
||||||
"""Executed once after all tests in the class"""
|
|
||||||
os.remove("version.rc")
|
os.remove("version.rc")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
import unittest
|
||||||
unittest.main(testRunner=TAPTestRunner())
|
unittest.main(testRunner=TAPTestRunner())
|
||||||
|
|
||||||
# vim: ai sts=4 et sw=4
|
# vim: ai sts=4 et sw=4
|
||||||
|
|||||||
Reference in New Issue
Block a user