From 9c18b9705d90e9d57723412a1a09078556187ee8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 11:53:41 +0100 Subject: [PATCH 1/7] fix entry point syntax for hatchling --- pyproject.toml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c951457..290e0cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,13 +25,8 @@ dependencies = [ "icecream", ] -[project.entry_points] -pytest11 = [ - "pytest_abra = pytest_abra.pytest_abra", -] - -[project.scripts] -abratest = "pytest_abra.cli:run" +[project.entry-points.pytest11] +pytest_abra = "pytest_abra.pytest_abra" [build-system] requires = ["hatchling"] -- 2.47.2 From 3b0edb97f7ca699ae2bb45f3bc2d985e8a7f85d8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 11:55:35 +0100 Subject: [PATCH 2/7] re-add cli script --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 290e0cd..20d9b07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,9 @@ dependencies = [ [project.entry-points.pytest11] pytest_abra = "pytest_abra.pytest_abra" +[project.scripts] +abratest = "pytest_abra.cli:run" + [build-system] requires = ["hatchling"] build-backend = "hatchling.build" -- 2.47.2 From 15a7f94a01e84cbd464d40c053b57f39efd5e884 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 11:58:30 +0100 Subject: [PATCH 3/7] make some cli arguments required --- pytest_abra/cli.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pytest_abra/cli.py b/pytest_abra/cli.py index 2b1dfa7..0d82951 100644 --- a/pytest_abra/cli.py +++ b/pytest_abra/cli.py @@ -11,14 +11,13 @@ from pytest_abra.utils import get_datetime_string def run(): parser = argparse.ArgumentParser() - parser.add_argument("--env_paths", type=str, help="List of loaded env files separated with ;") - parser.add_argument("--recipes_dir", type=Path, help="List of loaded env files separated with ;") - parser.add_argument("--output_dir", type=Path, help="List of loaded env files separated with ;") + parser.add_argument("--env_paths", type=str, help="List of loaded env files separated with ;", required=True) + parser.add_argument("--recipes_dir", type=Path, help="List of loaded env files separated with ;", required=True) + parser.add_argument("--output_dir", type=Path, help="List of loaded env files separated with ;", required=True) parser.add_argument("--timeout", type=int, help="Set Playwright timeout in ms", default=20_000) parser.add_argument("--debug", action="store_true", help="Enable Playwright debug mode") parser.add_argument("--resume", action="store_true", help="Re-run the most recent test, skipping passed tests") args = parser.parse_args() - ENV_FILES = [Path(s) for s in args.env_paths.split(";")] # -------------------------- enable playwright debug ------------------------- # -- 2.47.2 From 78cd4c126b2974062f3831609189315276ebcab4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 12:59:01 +0100 Subject: [PATCH 4/7] add recipes to pythonpath --- main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.py b/main.py index e7b02a2..9de2d4f 100644 --- a/main.py +++ b/main.py @@ -31,6 +31,13 @@ ENV_PATHS = ";".join([x.as_posix() for x in ENV_FILES]) RECIPES_DIR = Path("../recipes").resolve() OUTPUT_DIR = Path("./test-output").resolve() +# -------------------------------- pythonpath -------------------------------- # + +# add recipes dir to pythonpath, so that python imports from there are possible +# the custom classes of Runner will be imported from there +os.environ["PYTHONPATH"] = RECIPES_DIR.as_posix() + +# ------------------------------------ run ----------------------------------- # subprocess.run( [ -- 2.47.2 From abbc69afe4ab6e1c162ac1bcde86b736b17efc3b Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 12:59:14 +0100 Subject: [PATCH 5/7] use pip install -e . in dockerimage --- Dockerfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8a7efdd..609f0a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,13 @@ RUN playwright install RUN playwright install-deps -COPY ./requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +COPY . /code -WORKDIR /code \ No newline at end of file +WORKDIR /code + +RUN pip install --no-cache-dir -e . + +RUN rm -rf /code + +RUN ln -s /code/recipes /recipes +RUN ln -s /code/envfiles /envfiles -- 2.47.2 From dd9bc200681ba7068de3a1a334d8148ff8e5f181 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 12:59:19 +0100 Subject: [PATCH 6/7] update readme --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d3d3604..3418450 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ You can run pytest-abra with and without Docker. Choose now and follow the steps Create a python environment and install all dependencies via ```bash -pip install -r requirements.txt +pip install -e . playwright install ``` @@ -40,7 +40,8 @@ python main.py ```bash docker compose build # build the image -docker compose run --rm app ./run_pytest-abra.sh # run pytest-abra +docker compose run --rm app python main.py # run pytest-abra +docker compose run --rm -it app /bin/bash # debug the container ``` Force rebuild with cache @@ -49,7 +50,7 @@ Force rebuild with cache docker-compose up --build ``` -Force rebuild wtihtout cache +Force rebuild without cache ```bash docker-compose build --no-cache @@ -68,5 +69,5 @@ playwright codegen demo.playwright.dev/todomvc ```bash pytest # test pytest-abra pytest --collect-only # debug test pytest-abra -docker compose run --rm app ./test_pytest-abra.sh # test pytest-abra +docker compose run --rm app pytest # run pytest-abra ``` -- 2.47.2 From fb19a58dbda4f12aaebf5abb861e15d1ccb41d08 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 7 Dec 2023 13:01:00 +0100 Subject: [PATCH 7/7] remove deprecated sh scripts and requirements.txt --- requirements.txt | 9 --------- run_abratest.sh | 6 ------ test_abratest.sh | 7 ------- 3 files changed, 22 deletions(-) delete mode 100644 requirements.txt delete mode 100644 run_abratest.sh delete mode 100644 test_abratest.sh diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index be7218a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -pytest -pytest-html -pytest-playwright -python-dotenv -icecream -loguru -beautifulsoup4 -imbox -hatchling \ No newline at end of file diff --git a/run_abratest.sh b/run_abratest.sh deleted file mode 100644 index ddffb80..0000000 --- a/run_abratest.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -RECIPES_PATH=$PWD/recipes -export PYTHONPATH=${PYTHONPATH}:$RECIPES_PATH - -python main.py \ No newline at end of file diff --git a/test_abratest.sh b/test_abratest.sh deleted file mode 100644 index d7abaaa..0000000 --- a/test_abratest.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -PWD_PATH=$PWD -RECIPES_PATH=$PWD/recipes -export PYTHONPATH=$PWD_PATH:$RECIPES_PATH - -pytest \ No newline at end of file -- 2.47.2