Skip to content

Commit

Permalink
Merge pull request #519 from pybop-team/458-all-postional-args-for-no…
Browse files Browse the repository at this point in the history
…x-tests

Adds positional args for nox tests session
  • Loading branch information
BradyPlanden authored Sep 28, 2024
2 parents 735cdd7 + 46ae507 commit 4633951
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,24 @@ 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 test, alternatively you can run all tests within a file by removing the trailing `::test_costs` in the above command.

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
pytest tests/unit/path/to/test.py --unit -v
```

And for individual tests,
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

0 comments on commit 4633951

Please sign in to comment.