Skip to content
Myr

Some more cleanups in how the test runner is invoked

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 367b254 · Browse files · 2 files+27 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+27 added−12 removed

  • other:+27 added−12 removed

2 files+27 added−12 removed

modified:flask/testsuite/__init__.py+25 added-6 removed
19 unmodified lines
20from werkzeug.utils import import_string, find_modules212223def add_to_path(path):24 """Adds an entry to sys.path_info if it's not already there."""25 if not os.path.isdir(path):26 raise RuntimeError('Tried to add nonexisting path')2728 def _samefile(x, y):29 try:30 return os.path.samefile(x, y)31 except (IOError, OSError):
6 unmodified lines
38 pass39 sys.path.append(path)404138def setup_paths():39 add_to_path(os.path.abspath(os.path.join(40 os.path.dirname(__file__), 'test_apps')))414242def iter_suites():43 """Yields all testsuites."""44 for module in find_modules(__name__):45 mod = import_string(module)46 if hasattr(mod, 'suite'):47 yield mod.suite()484950def find_all_tests(suite):51 """Yields all the tests and their names from a given suite."""52 suites = [suite]53 while suites:54 s = suites.pop()55 try:
111 unmodified lines
167 rv.addTest(test)168 return rv169170171def setup_path():172 add_to_path(os.path.abspath(os.path.join(173 os.path.dirname(__file__), 'test_apps')))174175176def suite():177 """A testsuite that has all the Flask tests. You can use this178 function to integrate the Flask tests into your own testsuite179 in case you want to test that monkeypatches to Flask do not180 break it.181 """171 setup_paths()182 setup_path()183 suite = unittest.TestSuite()184 for other_suite in iter_suites():185 suite.addTest(other_suite)186 return suite187188189def main():190 """Runs the testsuite as command line application."""191 try:192 unittest.main(testLoader=BetterLoader(), defaultTest='suite')193 except Exception, e:194 print 'Error: %s' % e
modified:run-tests.py+2 added-6 removed
1import unittest2from flask.testsuite import BetterLoader3try:4 unittest.main(testLoader=BetterLoader(), defaultTest='suite')5except Exception, e:6 print 'Error: %s' % e1from flask.testsuite import main2main()