def django_list_tests(paths): from neurotic.integration import (find_settings_module, find_all_tests, find_apps) sys.path.append(os.getcwd()) sys.path.append(os.path.dirname(os.getcwd())) os.environ['DJANGO_SETTINGS_MODULE'] = find_settings_module(os.getcwd()) names = find_all_tests(find_apps(os.getcwd())) for name in names: print(name)
import sys import os from os.path import dirname, abspath, join test_path = "/".join(abspath(__file__).split('/')[:-1]) neurotic_path = join(test_path, '../') sys.path.append(neurotic_path) from neurotic.integration import find_apps, find_all_tests, find_settings_module # scenario 2 - app1/tests/__init__.py scenario2_path = join(test_path, join("fixtures", "proj2")) sys.path.append(scenario2_path) os.environ['DJANGO_SETTINGS_MODULE'] = find_settings_module(scenario2_path) assert ["app2.tests.test_views.DummyTestCase.test_dummy" ] == find_all_tests(find_apps(scenario2_path)) print("find_all_isolated_proj2 == OK") sys.path.remove(scenario2_path)
import sys import os from os.path import dirname, abspath, join test_path = "/".join(abspath(__file__).split('/')[:-1]) neurotic_path = join(test_path, '../') sys.path.append(neurotic_path) from neurotic.integration import find_apps, find_all_tests, find_settings_module # scenario 2 - app1/tests/__init__.py scenario2_path = join(test_path, join("fixtures", "proj2")) sys.path.append(scenario2_path) os.environ['DJANGO_SETTINGS_MODULE'] = find_settings_module(scenario2_path) assert ["app2.tests.test_views.DummyTestCase.test_dummy"] == find_all_tests(find_apps(scenario2_path)) print("find_all_isolated_proj2 == OK") sys.path.remove(scenario2_path)
import sys import os from os.path import dirname, abspath, join test_path = "/".join(abspath(__file__).split('/')[:-1]) neurotic_path = join(test_path, '../') sys.path.append(neurotic_path) from neurotic.integration import find_apps, find_all_tests, find_settings_module # scenario 2 - app1/tests/__init__.py scenario3_path = join(test_path, join("fixtures", "proj3")) sys.path.append(scenario3_path) os.environ['DJANGO_SETTINGS_MODULE'] = find_settings_module(scenario3_path) assert [] == find_all_tests(find_apps(scenario3_path)) print("find_all_isolated_proj3 == OK") sys.path.remove(scenario3_path)
import os import sys from os.path import dirname, abspath, join test_path = "/".join(abspath(__file__).split('/')[:-1]) neurotic_path = join(test_path, '../') sys.path.append(neurotic_path) from neurotic.integration import find_apps, find_all_tests, find_settings_module # scenario 1 - app1/tests.py scenario1_path = join(test_path, join("fixtures", "proj1")) sys.path.append(scenario1_path) os.environ['DJANGO_SETTINGS_MODULE'] = find_settings_module(scenario1_path) assert ["app1.tests.DummyTestCase.test_dummy"] == find_all_tests(find_apps(scenario1_path)) print("find_all_isolated_proj1 == OK") sys.path.remove(scenario1_path)