forked from theatlantic/django-nested-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.py
executable file
·55 lines (43 loc) · 1.71 KB
/
runtests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import os
import re
import warnings
import selenosis
# A dict for mapping test case classes to their import paths, to allow passing
# TestCaseClass.test_function as shorthand to runtests.py
TEST_CASE_MODULE_PATHS = {
'TestAdminWidgets': 'nested_admin.tests.admin_widgets.tests',
'TestWidgetMediaOrder': 'nested_admin.tests.admin_widgets.tests',
'TestGenericInlineAdmin': 'nested_admin.tests.gfk.tests',
'VisualComparisonTestCase': 'nested_admin.tests.one_deep.tests',
'TestDeepNesting': 'nested_admin.tests.three_deep.tests',
'TestStackedInlineAdmin': 'nested_admin.tests.two_deep.tests',
'TestTabularInlineAdmin': 'nested_admin.tests.two_deep.tests',
'TestSortablesWithExtra': 'nested_admin.tests.two_deep.tests',
'TestIdenticalPrefixes': 'nested_admin.tests.identical_prefixes.tests',
}
def expand_test_module(module):
module = os.path.normpath(module)
matches = re.search(r'^([^/.]+)(\.[^./]+)?$', module)
if not matches:
return module
cls, test_fn = matches.groups()
if not test_fn:
test_fn = ''
if cls not in TEST_CASE_MODULE_PATHS:
return module
return "%s.%s%s" % (TEST_CASE_MODULE_PATHS[cls], cls, test_fn)
class RunTests(selenosis.RunTests):
def execute(self, flags, test_labels):
test_labels = [expand_test_module(m) for m in test_labels]
super(RunTests, self).execute(flags, test_labels)
def main():
warnings.simplefilter("error", Warning)
warnings.filterwarnings(
"ignore",
"name used for saved screenshot does not match file type",
UserWarning)
runtests = RunTests("nested_admin.tests.settings", "nested_admin")
runtests()
if __name__ == '__main__':
main()