From 8aad8dad85f00e5d3ad32b1e3bed3337cccd4bcb Mon Sep 17 00:00:00 2001 From: Illia Date: Thu, 2 Feb 2023 16:52:06 +0200 Subject: [PATCH] perf: run pytest in parallel Sample output: platform linux -- Python 3.10.9, pytest-7.2.1, pluggy-1.0.0 rootdir: /home/ilyazub/Workspace/google-search-results-python plugins: parallel-0.1.1 collected 48 pytest-parallel: 8 workers (processes), 6 tests per worker (threads) `py` dependency is used because pytest-parallel depends on it but doesn't require :confused: https://github.com/kevlened/pytest-parallel/issues/118 Co-authored-by: Dimitry --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2442e98..d8431eb 100644 --- a/Makefile +++ b/Makefile @@ -12,19 +12,23 @@ clean: find . -type d -name "__pycache__" -delete pip3 uninstall google_search_results +create_env: + python -m venv .env + source .env/bin/activate + install: python3 -m pip install --upgrade pip if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi -lint: +lint: build_dep # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics # Test with Python 3 -test: - pytest +test: build_dep + pytest --workers auto --tests-per-worker auto # run example only # and display output (-s) @@ -32,7 +36,7 @@ example: pytest -s "tests/test_example.py::TestExample::test_async" build_dep: - pip3 install -U setuptools pytest flake8 + pip3 install -U setuptools pytest py pytest-parallel flake8 # https://packaging.python.org/tutorials/packaging-projects/ build: