Merge branch '2.4.0' of ssh://git.tasktools.org/tm/task into 2.4.0

This commit is contained in:
Paul Beckingham 2014-04-13 16:43:30 -04:00
commit 9ad5502ad5
5 changed files with 24 additions and 34 deletions

View file

@ -83,7 +83,8 @@ class BaseTestCase(unittest.TestCase):
"""
pass
def callTask(self, args, input=None, merge_streams=True):
@classmethod
def callTask(cls, args, input=None, merge_streams=True):
"""Invoke src/task with the given arguments
Use callTaskSuccess or callTaskError if you want exit_code to be tested
@ -122,7 +123,8 @@ class BaseTestCase(unittest.TestCase):
return p.returncode, out, err
def callTaskSuccess(self, args, input=None, merge_streams=True):
@classmethod
def callTaskSuccess(cls, args, input=None, merge_streams=True):
"""Invoke src/task with the given arguments and expect a zero exit
code.
Causes test to fail if exit_code != 0
@ -134,13 +136,14 @@ class BaseTestCase(unittest.TestCase):
Returns (exit_code, stdout, stderr)
"""
out = self.callTask(args, input, merge_streams)
out = cls.callTask(args, input, merge_streams)
self.assertEqual(out[0], 0, "Task finished with non-zero ({0}) exit "
"code".format(out[0]))
assert out[0] == 0, ("Task finished with non-zero ({0}) exit code\n"
"OUTPUT: {1}".format(out[0], out[1]))
return out
def callTaskError(self, args, input=None, merge_streams=True):
@classmethod
def callTaskError(cls, args, input=None, merge_streams=True):
"""Invoke src/task with the given arguments and expect a non-zero exit
code.
Causes test to fail if exit_code == 0
@ -152,9 +155,9 @@ class BaseTestCase(unittest.TestCase):
Returns (exit_code, stdout, stderr)
"""
out = self.callTask(args, input, merge_streams)
out = cls.callTask(args, input, merge_streams)
self.assertNotEqual(out[0], 0, "Task finished with zero exit (0) code")
assert out[0] != 0, "Task finished with zero exit (0) code"
return out

View file

@ -51,7 +51,7 @@ class BaseTestBug1254(BaseTestCase):
os.remove(file)
@classmethod
def cleanup(cls):
def finish(cls):
os.remove("bug.rc")

View file

@ -59,7 +59,7 @@ class BaseTestBug360(BaseTestCase):
os.remove(file)
@classmethod
def cleanup(cls):
def finish(cls):
os.remove("bug.rc")

View file

@ -43,15 +43,11 @@ class BaseTestBug1300(BaseTestCase):
fh.write("data.location=.\n"
"confirmation=no\n")
def tearDown(self):
"""Needed after each test or setUp will cause duplicated data at start
of the next test.
"""
@classmethod
def finish(cls):
for file in glob("*.data"):
os.remove(file)
@classmethod
def cleanup(cls):
os.remove("bug.rc")

View file

@ -44,9 +44,6 @@ class BaseTest285(BaseTestCase):
"verbose=nothing\n"
"confirmation=no\n")
def setUp(self):
"""Executed before each test in the class"""
# OVERDUE YESTERDAY DUE TODAY TOMORROW WEEK MONTH YEAR
# due:-1week Y - - - - ? ? ?
# due:-1day Y Y - - - ? ? ?
@ -56,27 +53,21 @@ class BaseTest285(BaseTestCase):
# due:1month - - - - - - - ?
# due:1year - - - - - - - -
self.callTaskSuccess(['rc:bug.rc', 'add', 'due_last_week', 'due:-1week'])
self.callTaskSuccess(['rc:bug.rc', 'add', 'due_yesterday', 'due:-1day'])
self.callTaskSuccess(['rc:bug.rc', 'add', 'due_earlier_today', 'due:today'])
self.callTaskSuccess(['rc:bug.rc', 'add', 'due_later_today', 'due:tomorrow'])
self.callTaskSuccess(['rc:bug.rc', 'add', 'due_three_days', 'due:3days'])
self.callTaskSuccess(['rc:bug.rc', 'add', 'due_next_month', 'due:1month'])
self.callTaskSuccess(['rc:bug.rc', 'add', 'due_next_year', 'due:1year'])
def tearDown(self):
"""Needed after each test or setUp will cause duplicated data at start
of the next test.
"""
for file in glob("*.data"):
os.remove(file)
cls.callTaskSuccess(['rc:bug.rc', 'add', 'due_last_week', 'due:-1week'])
cls.callTaskSuccess(['rc:bug.rc', 'add', 'due_yesterday', 'due:-1day'])
cls.callTaskSuccess(['rc:bug.rc', 'add', 'due_earlier_today', 'due:today'])
cls.callTaskSuccess(['rc:bug.rc', 'add', 'due_later_today', 'due:tomorrow'])
cls.callTaskSuccess(['rc:bug.rc', 'add', 'due_three_days', 'due:3days'])
cls.callTaskSuccess(['rc:bug.rc', 'add', 'due_next_month', 'due:1month'])
cls.callTaskSuccess(['rc:bug.rc', 'add', 'due_next_year', 'due:1year'])
@classmethod
def finish(cls):
os.remove("bug.rc")
for file in glob("*.data"):
os.remove(file)
os.remove("bug.rc")
class Test285(BaseTest285):
def test_overdue(self):