On Thu, Jul 8, 2010 at 10:59 AM, Nick Coghlan <ncoghlan at gmail.com> wrote: .. > I realised during the day that my suggested approach was more > complicated than is actually necessary - once the existing tests have > been moved to a separate module, *that test module* can itself be > imported twice, once with the python version of the module to be > tested and once with the C version. You can then do some hackery to > distinguish the test classes without having to modify the test code > itself (note, the below code should work in theory, but isn't actually > tested): > > ============= > py_module_tests = support.import_fresh_module('moduletester', > fresh=['modulename'], blocked=['_modulename']) > c_module_tests = support.import_fresh_module('moduletester', > fresh=['modulename', '_modulename']) > > test_modules = [py_module_tests, c_module_tests] > suffixes = ["_Py", "_C"] > > for module, suffix in zip(test_modules, suffixes): > for obj in module.itervalues(): > if isinstance(obj, unittest,TestCase): > obj.__name__ += suffix > setattr(module, obj.__name__, obj) > > def test_main(): > for module in test_modules: > module.test_main() > ============= Yes, this is definitely an improvement over my current datetime patch [1]_, but it still requires a custom test_main() and does not make the test cases discoverable by alternative unittest runners. I think that can be fixed by injecting imported TestCase subclasses into the main test module globals. I'll try to implement that for datetime. Thanks, Nick - great idea! .. [1] http://bugs.python.org/file17848/issue7989.diff
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4