cleanup
This commit is contained in:
parent
bee347f13f
commit
3fe9ed28db
1 changed files with 8 additions and 32 deletions
|
|
@ -20,13 +20,14 @@ def condition_always_true(dotenv_path: Path) -> bool:
|
|||
|
||||
|
||||
class Runner:
|
||||
test_dir: Optional[str] = None
|
||||
main_test_name: Optional[str] = None
|
||||
sub_tests: list[SubTest] = []
|
||||
|
||||
def __init__(self, dotenv_path: Path):
|
||||
assert self.test_dir is not None
|
||||
self.dotenv_path = dotenv_path
|
||||
self.root_dir = self.dotenv_path.parent
|
||||
self.load_dotenv()
|
||||
# self.root_dir = self.dotenv_path.parent
|
||||
|
||||
def _run_main_test(self):
|
||||
if isinstance(self.main_test_name, str):
|
||||
|
|
@ -35,7 +36,7 @@ class Runner:
|
|||
def _run_pytest(self, test_name: str):
|
||||
pytest.main(
|
||||
[
|
||||
self.root_dir / "tests_wordpress" / test_name,
|
||||
self.root_dir / self.test_dir / test_name,
|
||||
"--env_file_path",
|
||||
self.dotenv_path,
|
||||
]
|
||||
|
|
@ -46,41 +47,16 @@ class Runner:
|
|||
|
||||
def run_tests(self):
|
||||
self._run_main_test()
|
||||
for c in self.sub_tests:
|
||||
condition_function = c["condition"]
|
||||
for sub_test in self.sub_tests:
|
||||
condition_function = sub_test["condition"]
|
||||
if condition_function():
|
||||
test_name = c["test_file"]
|
||||
test_name = sub_test["test_file"]
|
||||
self._run_pytest(test_name)
|
||||
|
||||
|
||||
class RunnerWordpress(Runner):
|
||||
test_dir = "tests_wordpress"
|
||||
main_test_name = "test_wordpress.py"
|
||||
sub_tests = [
|
||||
SubTest(condition=condition_always_true, test_file="test_wordpress_feature1.py")
|
||||
]
|
||||
|
||||
def load_dotenv(self):
|
||||
assert self.dotenv_path.is_file()
|
||||
config = dotenv_values(self.dotenv_path)
|
||||
ic(config)
|
||||
|
||||
def run_pytest_dir_wp(self):
|
||||
pytest.main([self.root_dir / "tests_wordpress"])
|
||||
|
||||
def run_pytest_single_wp(self):
|
||||
pytest.main(
|
||||
[
|
||||
self.root_dir / "tests_wordpress" / "test_wordpress.py",
|
||||
"--env_file_path",
|
||||
self.dotenv_path,
|
||||
]
|
||||
)
|
||||
|
||||
def run_pytest_single_wp_feature1(self):
|
||||
pytest.main(
|
||||
[
|
||||
self.root_dir / "tests_wordpress" / "test_wordpress_feature1.py",
|
||||
"--env_file_path",
|
||||
self.dotenv_path,
|
||||
]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue