diff options
author | Gerhard Weis <g.weis@griffith.edu.au> | 2014-02-27 11:13:44 +1000 |
---|---|---|
committer | Gerhard Weis <g.weis@griffith.edu.au> | 2014-02-27 11:13:44 +1000 |
commit | 80a8e6d13778252f626dfb8d7503648335e23482 (patch) | |
tree | df00a07909317af1de21bf7201bb194e1e2f2bc8 /src/isodate/tests/test_date.py | |
parent | 308302303068ecd149957a958c9d71625771c0f9 (diff) | |
download | isodate-80a8e6d13778252f626dfb8d7503648335e23482.tar.gz |
make flake happy
Diffstat (limited to 'src/isodate/tests/test_date.py')
-rw-r--r-- | src/isodate/tests/test_date.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/isodate/tests/test_date.py b/src/isodate/tests/test_date.py index 3a1b4a6..fdc1043 100644 --- a/src/isodate/tests/test_date.py +++ b/src/isodate/tests/test_date.py @@ -14,11 +14,11 @@ # may be used to endorse or promote products derived from this software # without specific prior written permission. # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN @@ -66,20 +66,21 @@ TEST_CASES = {4: [('19', date(1901, 1, 1), DATE_CENTURY), ('+001985W15', date(1985, 4, 8), DATE_BAS_WEEK), ('+001985-W15', date(1985, 4, 8), DATE_EXT_WEEK)]} + def create_testcase(yeardigits, datestring, expectation, format): ''' Create a TestCase class for a specific test. - + This allows having a separate TestCase for each test tuple from the TEST_CASES list, so that a failed test won't stop other tests. ''' - + class TestDate(unittest.TestCase): ''' A test case template to parse an ISO date string into a date object. ''' - + def test_parse(self): ''' Parse an ISO date string and compare it to the expected value. @@ -90,7 +91,7 @@ def create_testcase(yeardigits, datestring, expectation, format): else: result = parse_date(datestring, yeardigits) self.assertEqual(result, expectation) - + def test_format(self): ''' Take date object and create ISO string from it. @@ -98,15 +99,16 @@ def create_testcase(yeardigits, datestring, expectation, format): ''' if expectation is None: self.assertRaises(AttributeError, - date_isoformat, expectation, format, - yeardigits) + date_isoformat, expectation, format, + yeardigits) else: self.assertEqual(date_isoformat(expectation, format, yeardigits), datestring) - + return unittest.TestLoader().loadTestsFromTestCase(TestDate) + def test_suite(): ''' Construct a TestSuite instance for all test cases. @@ -118,9 +120,10 @@ def test_suite(): expectation, format)) return suite + # load_tests Protocol def load_tests(loader, tests, pattern): return test_suite() - + if __name__ == '__main__': unittest.main(defaultTest='test_suite') |