Make sure both 'python -m pytest' and 'pytest' run your tests.
Project description
Run a series of test invocation making sure each test case works with both 'pytest' and 'python -m pytest' over all working directories between the project root and the directory containing the test script.
├─ src
│
│<-- # run selected __main__'s from this working directory
│
│ └─ __init__.py
│ └─ foo.py
│ ├─ bar
│ │ └─ __init__.py
│ │ └─ bar.py
│ │
│ │<-- # run selected __main__'s from this working directory
│ │
│ └─ run_foo_main.py
│ └─ run_bar_main.py
│
│<-- # run selected test cases from this working directory
│
├─ tests
│ │
│ │<-- # run selected test cases from this working directory
│ │
│ └─ test_foo.py
│ └─ bar
│ │<-- # run selected bar test cases from this working directory
│ │
│ └─ test_bar.py
└─ setup.py
Your run_all_my_tests.py
:
from run_all_the_tests import TestCasePath, TestCase, Group, TestType
if __name__ == '__main__':
project_path: PurePath = Path(__file__).absolute().parent.parent
def gen_test_case_path(test_case: str) -> TestCasePath:
return TestCasePath(project_path, PurePath(test_case))
all_test_cases: Tuple[TestCase, ...] = (
TestCase.gen_test_case(gen_test_case_path('tests/test_foo.py')),
TestCase.gen_test_case(gen_test_case_path('tests/bar/test_bar.py')),
)
run_all_tests(all_test_cases)
Each set of tests are run in parallel within Group.ONE
. Designate
tests to run within non-conflicting groups of parallel runs by assigning
all test cases that can run without conflict to the same Group
.
all_test_cases: Tuple[TestCase, ...] = (
TestCase.gen_test_case(gen_test_case_path('tests/test_foo.py')),
TestCase.gen_test_case(gen_test_case_path('tests/bar/test_bar.py'), Group.TWO),
)
TestCase.gen_test_case()
also supports the following agrs:
pytest_filter: str = None
:param pytest_filter: pytest -k string
test_types: Tuple[TestType, ...] = TestType.all_test_types()
:param test_types: for exceptional situations, limit a TestCase to run for limited set of TestType's
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for run_all_the_tests-0.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb26df8fcb4e5671db4b14ff4fabdf33e7a94f21b6bedc7dc2f74bb40387afc6 |
|
MD5 | 7b13126e32ee740c8657611b0f3bd8a1 |
|
BLAKE2b-256 | a7af68765ce93e22a3a592a7d1fba6d1423dd923ec08368f9320d49eb4edb64e |