annotate Lib/test/test_datetime.py @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 01e5d0771824
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63184
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
1 import unittest
61996
cac00cbbe770 Merged revisions 81556 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 61953
diff changeset
2 import sys
63184
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
3 from test.support import import_fresh_module, run_unittest
75086
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
4
63184
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
5 TESTS = 'test.datetimetester'
75086
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
6
63184
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
7 # XXX: import_fresh_module() is supposed to leave sys.module cache untouched,
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
8 # XXX: but it does not, so we have to save and restore it ourselves.
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
9 save_sys_modules = sys.modules.copy()
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
10 try:
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
11 pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'],
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
12 blocked=['_datetime'])
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
13 fast_tests = import_fresh_module(TESTS, fresh=['datetime',
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
14 '_datetime', '_strptime'])
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
15 finally:
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
16 sys.modules.clear()
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
17 sys.modules.update(save_sys_modules)
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
18 test_modules = [pure_tests, fast_tests]
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
19 test_suffixes = ["_Pure", "_Fast"]
75086
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
20 # XXX(gb) First run all the _Pure tests, then all the _Fast tests. You might
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
21 # not believe this, but in spite of all the sys.modules trickery running a _Pure
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
22 # test last will leave a mix of pure and native datetime stuff lying around.
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
23 test_classes = []
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
24
63184
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
25 for module, suffix in zip(test_modules, test_suffixes):
afdb53323065 Issue #7989: Added pure python implementation of the datetime module.
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 62837
diff changeset
26 for name, cls in module.__dict__.items():
75086
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
27 if not (isinstance(cls, type) and issubclass(cls, unittest.TestCase)):
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
28 continue
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
29 cls.__name__ = name + suffix
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
30 @classmethod
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
31 def setUpClass(cls_, module=module):
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
32 cls_._save_sys_modules = sys.modules.copy()
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
33 sys.modules[TESTS] = module
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
34 sys.modules['datetime'] = module.datetime_module
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
35 sys.modules['_strptime'] = module._strptime
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
36 @classmethod
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
37 def tearDownClass(cls_):
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
38 sys.modules.clear()
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
39 sys.modules.update(cls_._save_sys_modules)
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
40 cls.setUpClass = setUpClass
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
41 cls.tearDownClass = tearDownClass
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
42 test_classes.append(cls)
33498
abbdbba56a8b SF bug #1028306: date-datetime comparison
Tim Peters <tim.peters@gmail.com>
parents: 32388
diff changeset
43
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
44 def test_main():
75086
01e5d0771824 Fix obscure failures of datetime-related tests due to the datetime tests failing to restore the system state completely after testing the pure-Python versions.
Georg Brandl <georg@python.org>
parents: 68586
diff changeset
45 run_unittest(*test_classes)
26673
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
46
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
47 if __name__ == "__main__":
5b715cad34d0 datetime escapes the sandbox. The Windows build is all set. I leave it
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
48 test_main()