Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
58 lines (48 loc) · 1.66 KB

File metadata and controls

58 lines (48 loc) · 1.66 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
56
57
"""
Simple auto test discovery.
From http://stackoverflow.com/a/17004409
"""
import os
import sys
import unittest
if not hasattr(unittest.defaultTestLoader, 'discover'):
try:
import unittest2 as unittest
except ImportError:
raise ImportError('The unittest2 module is required to run tests on Python 2.6')
def additional_tests():
setup_file = sys.modules['__main__'].__file__
setup_dir = os.path.abspath(os.path.dirname(setup_file))
test_dir = os.path.join(setup_dir, 'tests')
test_suite = unittest.defaultTestLoader.discover(test_dir)
blacklist = []
if '/home/travis' in __file__:
# Skip some tests that fail on travis-ci
blacklist.append('test_command')
return exclude_tests(test_suite, blacklist)
class SkipCase(unittest.TestCase):
def skeleton_run_test(self):
raise unittest.SkipTest("Test fails spuriously on travis-ci")
def exclude_tests(suite, blacklist):
"""
Example:
blacklist = [
'test_some_test_that_should_be_skipped',
'test_another_test_that_should_be_skipped'
]
"""
new_suite = unittest.TestSuite()
for test_group in suite._tests:
for test in test_group:
if not hasattr(test, '_tests'):
# e.g. ModuleImportFailure
new_suite.addTest(test)
continue
for subtest in test._tests:
method = subtest._testMethodName
if method in blacklist:
setattr(test,
method,
getattr(SkipCase(), 'skeleton_run_test'))
new_suite.addTest(test)
return new_suite
Morty Proxy This is a proxified and sanitized view of the page, visit original site.