test_handler: Separate test title from path to discover tests.
This commit is contained in:
parent
a6a5da2653
commit
52ab8cc44e
|
@ -9,8 +9,8 @@ import pytest
|
||||||
TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
os.chdir(os.path.dirname(TOOLS_DIR))
|
os.chdir(os.path.dirname(TOOLS_DIR))
|
||||||
|
|
||||||
def handle_input_and_run_tests_for_package(package_name):
|
def handle_input_and_run_tests_for_package(package_name, path_list):
|
||||||
parser = argparse.ArgumentParser(description="Run tests for the {} package.".format(package_name))
|
parser = argparse.ArgumentParser(description="Run tests for {}.".format(package_name))
|
||||||
parser.add_argument('--coverage',
|
parser.add_argument('--coverage',
|
||||||
nargs='?',
|
nargs='?',
|
||||||
const=True,
|
const=True,
|
||||||
|
@ -34,7 +34,7 @@ def handle_input_and_run_tests_for_package(package_name):
|
||||||
cov.start()
|
cov.start()
|
||||||
|
|
||||||
if options.pytest:
|
if options.pytest:
|
||||||
location_to_run_in = os.path.join(TOOLS_DIR, '..', package_name)
|
location_to_run_in = os.path.join(TOOLS_DIR, '..', *path_list)
|
||||||
paths_to_test = ['.']
|
paths_to_test = ['.']
|
||||||
pytest_options = [
|
pytest_options = [
|
||||||
'-s', # show output from tests; this hides the progress bar though
|
'-s', # show output from tests; this hides the progress bar though
|
||||||
|
@ -50,7 +50,7 @@ def handle_input_and_run_tests_for_package(package_name):
|
||||||
else:
|
else:
|
||||||
# Codecov seems to work only when using loader.discover. It failed to capture line executions
|
# Codecov seems to work only when using loader.discover. It failed to capture line executions
|
||||||
# for functions like loader.loadTestFromModule or loader.loadTestFromNames.
|
# for functions like loader.loadTestFromModule or loader.loadTestFromNames.
|
||||||
test_suites = unittest.defaultTestLoader.discover(package_name)
|
test_suites = unittest.defaultTestLoader.discover(os.path.join(*path_list))
|
||||||
suite = unittest.TestSuite(test_suites)
|
suite = unittest.TestSuite(test_suites)
|
||||||
runner = unittest.TextTestRunner(verbosity=2)
|
runner = unittest.TextTestRunner(verbosity=2)
|
||||||
result = runner.run(suite)
|
result = runner.run(suite)
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
from server_lib.test_handler import handle_input_and_run_tests_for_package
|
from server_lib.test_handler import handle_input_and_run_tests_for_package
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
handle_input_and_run_tests_for_package('zulip_botserver')
|
handle_input_and_run_tests_for_package('Botserver', ['zulip_botserver'])
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
from server_lib.test_handler import handle_input_and_run_tests_for_package
|
from server_lib.test_handler import handle_input_and_run_tests_for_package
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
handle_input_and_run_tests_for_package('zulip')
|
handle_input_and_run_tests_for_package('API', ['zulip'])
|
||||||
|
|
Loading…
Reference in a new issue