Skip to content

Commit 60b186f

Browse files
committed
test: unify test loading on Python 2 & 3
On Python 3 load_tests() function that is defined in unit/suites/__init__.py is called to filter unittest.TestCase classes to run. On Python 2 the function is not called and all unittest.TestCase classes are subject to run. I plan to define a hierarchy of test cases in the schema reload test and exclude the base class from the list to run, so this behaviour is not desired. The reason of the difference between unittest behaviour on Python 2 and Python 3 is described in the TestLoader#discover() function documentation (see [1]): | Changed in version 3.5: Found packages are now checked for load_tests | regardless of whether their path matches pattern, because it is | impossible for a package name to match the default pattern. The default pattern is 'test*.py'. [1]: https://docs.python.org/3/library/unittest.html#unittest.TestLoader.discover
1 parent 3a915f1 commit 60b186f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

unit/setup_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def run(self):
2323
Find all tests in test/tarantool/ and run them
2424
'''
2525

26-
tests = unittest.defaultTestLoader.discover('unit')
26+
tests = unittest.defaultTestLoader.discover('unit', pattern='suites')
2727
test_runner = unittest.TextTestRunner(verbosity=2)
2828
result = test_runner.run(tests)
2929
if not result.wasSuccessful():

0 commit comments

Comments
 (0)