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

infra: add offline unit tests #939

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ You can also pass in various pytest arguments to run selected tests:
tox -e unit-tests -- your-arguments
```

Running unit-tests offline is possible if all packages are installed ahead of time. Note that this may result in out of date packages so testing done this way is not to be considered reliable:
```bash
INSTALL_DIR=$(pip show pip | grep Location | sed -e "s/^Location: //") tox -e offline-tests
```

For more information, please see [pytest usage](https://docs.pytest.org/en/stable/usage.html).

To run linters and doc generators and unit tests:
Expand Down
12 changes: 11 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tox]
envlist = clean,linters,docs,unit-tests


[testenv]
parallel_show_output = true
package = wheel
Expand All @@ -12,6 +11,17 @@ deps = coverage
skip_install = true
commands = coverage erase

[testenv:offline-tests]
usedevelop=True
basepython = python3
passenv =
INSTALL_DIR
install_command=python -m pip install {opts} --no-index --find-links {env:INSTALL_DIR:} {packages}
# {posargs} contains additional arguments specified when invoking tox. e.g. tox -- -s -k test_foo.py
commands =
pytest {posargs} --cov=braket --cov-report term-missing --cov-report html --cov-report xml --cov-append
extras = test

[testenv:unit-tests]
usedevelop=True
basepython = python3
Expand Down