Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds positional args for nox tests session #519

Merged
merged 3 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,21 @@ If you have nox installed, to run unit tests, type
nox -s unit
```

Alternatively, to run tests standalone with pytest, run,
For individual tests, use:

```bash
nox -s tests -- tests/unit/test_costs.py::TestCosts::test_costs
```

which will run the specified cost, alternatively you can run all tests within a file by removing the trailing `::test_costs` in the above command.
BradyPlanden marked this conversation as resolved.
Show resolved Hide resolved

Alternatively, to run tests standalone with pytest, use:

```bash
pytest --unit -v
```

To run individual test files, you can use
To run individual test files with nox, you can use

```bash
pytest tests/unit/path/to/test --unit -v
BradyPlanden marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
12 changes: 10 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,20 @@ def notebooks_overwrite(session):

@nox.session(name="tests")
def run_tests(session):
"""Run all the tests."""
"""Run all or a user-defined set of tests."""
session.install("-e", ".[all,dev]", silent=False)
if PYBOP_SCHEDULED:
session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False)
specific_tests = session.posargs if session.posargs else []
session.run(
"pytest", "--unit", "--integration", "--nbmake", "--examples", "-n", "auto"
"pytest",
"--unit",
"--integration",
"--nbmake",
"--examples",
"-n",
"auto",
*specific_tests,
)


Expand Down
Loading