From 13d79618136a3aa1c5e97c19af2d20100a31415e Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sun, 13 Apr 2014 20:12:55 +0100 Subject: [PATCH] Refactor some tests to avoid redoing setUp/tearDown once per test --- test/tw-1300.t | 8 ++------ test/tw-285.t | 27 +++++++++------------------ 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/test/tw-1300.t b/test/tw-1300.t index 696d7c611..aed8b8285 100755 --- a/test/tw-1300.t +++ b/test/tw-1300.t @@ -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 finish(cls): os.remove("bug.rc") diff --git a/test/tw-285.t b/test/tw-285.t index bec498c59..79fa86818 100755 --- a/test/tw-285.t +++ b/test/tw-285.t @@ -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):