diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 41cfeeb..4bad241 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -61,4 +61,4 @@ body: label: Existing GitHub issues options: - label: I have searched existing GitHub issues to make sure the issue does not already exist. - required: true \ No newline at end of file + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 34051e4..9ca5a64 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -41,4 +41,4 @@ body: attributes: label: Additional information description: | - Please provide any additional information here. Include potential alternative solutions, or workarounds, as well as references, if any. \ No newline at end of file + Please provide any additional information here. Include potential alternative solutions, or workarounds, as well as references, if any. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ee67225..c400f91 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -17,6 +17,9 @@ Please complete the following checklist when submitting a PR. The PR will not be - [ ] The code is formatted using Black. You can do this by running `black src tests`. +- +- [ ] The imports are sorted using isort. + You can do this by running `isort src tests`. - [ ] The code is type-checked using Mypy. You can do this by running `mypy src tests`. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eee80f0..0d16352 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,6 +38,7 @@ jobs: run: | . ./venv/bin/activate black src tests --check --diff + isort src tests --check-only --diff - name: Test Typing run: | . ./venv/bin/activate @@ -45,7 +46,7 @@ jobs: - name: Test Notebooks run: | . ./venv/bin/activate - pytest --nbmake notebooks --nbmake-timeout=600 # 10 minutes timeout + pytest --nbmake notebooks -n=auto --nbmake-kernel=python3 --nbmake-timeout=600 # 10 minutes timeout - name: Test Unittests with pytest run: | diff --git a/poetry.lock b/poetry.lock index b4297dd..c762c07 100644 --- a/poetry.lock +++ b/poetry.lock @@ -644,6 +644,22 @@ typing-extensions = {version = ">=4.6.0", markers = "python_version < \"3.13\""} [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "2.1.1" +description = "execnet: rapid multi-Python deployment" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "execnet-2.1.1-py3-none-any.whl", hash = "sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc"}, + {file = "execnet-2.1.1.tar.gz", hash = "sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3"}, +] + +[package.extras] +testing = ["hatch", "pre-commit", "pytest", "tox"] + [[package]] name = "executing" version = "2.2.0" @@ -855,6 +871,23 @@ qtconsole = ["qtconsole"] test = ["packaging", "pickleshare", "pytest", "pytest-asyncio (<0.22)", "testpath"] test-extra = ["curio", "ipython[test]", "jupyter_ai", "matplotlib (!=3.2.0)", "nbformat", "numpy (>=1.23)", "pandas", "trio"] +[[package]] +name = "isort" +version = "6.0.1" +description = "A Python utility / library to sort Python imports." +optional = false +python-versions = ">=3.9.0" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "isort-6.0.1-py3-none-any.whl", hash = "sha256:2dc5d7f65c9678d94c88dfc29161a320eec67328bc97aad576874cb4be1e9615"}, + {file = "isort-6.0.1.tar.gz", hash = "sha256:1cb5df28dfbc742e490c5e41bad6da41b805b0a8be7bc93cd0fb2a8a890ac450"}, +] + +[package.extras] +colors = ["colorama"] +plugins = ["setuptools"] + [[package]] name = "jaraco-classes" version = "3.4.0" @@ -1934,6 +1967,28 @@ pytest = ">=7.0.0" [package.extras] test = ["black (>=22.1.0)", "flake8 (>=4.0.1)", "pre-commit (>=2.17.0)", "tox (>=3.24.5)"] +[[package]] +name = "pytest-xdist" +version = "3.7.0" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "pytest_xdist-3.7.0-py3-none-any.whl", hash = "sha256:7d3fbd255998265052435eb9daa4e99b62e6fb9cfb6efd1f858d4d8c0c7f0ca0"}, + {file = "pytest_xdist-3.7.0.tar.gz", hash = "sha256:f9248c99a7c15b7d2f90715df93610353a485827bc06eefb6566d23f6400f126"}, +] + +[package.dependencies] +execnet = ">=2.1" +pytest = ">=7.0.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -2988,4 +3043,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.10,<4" -content-hash = "79986463da68857efceb8eddc41857db769cd32828660d83be6971655a680da9" +content-hash = "9cc6cc382d0569c9c4a01b4bd7217da579c6bb37a51e2eaf9c55881a33406c8c" diff --git a/pyproject.toml b/pyproject.toml index ab1155f..ff96af6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,8 @@ nbmake = "^1.5.5" wheel = "^0.45.1" build = "^1.2.2.post1" twine = "^6.1.0" +pytest-xdist = "^3.7.0" +isort = "^6.0.1" [tool.poetry.group.docs.dependencies] diff --git a/run_pytests.py b/run_pytests.py index dbc62c0..3be809a 100644 --- a/run_pytests.py +++ b/run_pytests.py @@ -70,6 +70,7 @@ def main(): f"--cov-report={args.cov_report}", f"--cov-report=term-missing", f"--durations={args.durations}", + f"-n=auto", ] pytest.main(pytest_main_args, plugins=[json_plugin]) json_path = os.path.join(args.tests_folder, ".tmp", f"tests_report_rn{configs.N_RANDOM_TESTS_PER_CASE}.json") diff --git a/tests/__init__.py b/tests/__init__.py index 5a078d3..95af403 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,6 @@ -import pytest import numpy as np +import pytest + from .configs import TEST_SEED np.random.seed(TEST_SEED) diff --git a/tests/conftest.py b/tests/conftest.py index d3672af..b458970 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import pytest + from .configs import RUN_SLOW_TESTS RUN_SLOW_ARG_NAME = "run_slow" diff --git a/tests/test_dummy.py b/tests/test_dummy.py index f7c2a96..bfaa4dc 100644 --- a/tests/test_dummy.py +++ b/tests/test_dummy.py @@ -1,9 +1,10 @@ import argparse +import runpy import pytest + import python_template -from python_template.__main__ import main, get_args_parser -import runpy +from python_template.__main__ import get_args_parser, main @pytest.mark.parametrize("dummy", list(range(10)))