mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Test flexibility (#4945)
* Add option to specify which tests to run in invoke test * Add information on testing in CONTRIBUTING.md
This commit is contained in:
parent
4d9e92011e
commit
11c5ce5f80
@ -123,6 +123,18 @@ The InvenTree code base makes use of [GitHub actions](https://github.com/feature
|
|||||||
|
|
||||||
The various github actions can be found in the `./github/workflows` directory
|
The various github actions can be found in the `./github/workflows` directory
|
||||||
|
|
||||||
|
### Run tests locally
|
||||||
|
|
||||||
|
To run test locally, use:
|
||||||
|
```
|
||||||
|
invoke test
|
||||||
|
```
|
||||||
|
|
||||||
|
To run only partial tests, for example for a module use:
|
||||||
|
```
|
||||||
|
invoke test --runtest order
|
||||||
|
```
|
||||||
|
|
||||||
## Code Style
|
## Code Style
|
||||||
|
|
||||||
Sumbitted Python code is automatically checked against PEP style guidelines. Locally you can run `invoke style` to ensure the style checks will pass, before submitting the PR.
|
Sumbitted Python code is automatically checked against PEP style guidelines. Locally you can run `invoke style` to ensure the style checks will pass, before submitting the PR.
|
||||||
|
22
tasks.py
22
tasks.py
@ -561,16 +561,30 @@ def test_translations(c):
|
|||||||
os.environ['TEST_TRANSLATIONS'] = 'True'
|
os.environ['TEST_TRANSLATIONS'] = 'True'
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task(
|
||||||
def test(c, disable_pty=False):
|
help={
|
||||||
"""Run unit-tests for InvenTree codebase."""
|
'disable_pty': 'Disable PTY',
|
||||||
|
'runtest': 'Specify which tests to run, in format <module>.<file>.<class>.<method>',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def test(c, disable_pty=False, runtest=''):
|
||||||
|
"""Run unit-tests for InvenTree codebase.
|
||||||
|
|
||||||
|
To run only certain test, use the argument --runtest.
|
||||||
|
This can filter all the way down to:
|
||||||
|
<module>.<file>.<class>.<method>
|
||||||
|
|
||||||
|
Example:
|
||||||
|
test --runtest=company.test_api
|
||||||
|
will run tests in the company/test_api.py file.
|
||||||
|
"""
|
||||||
# Run sanity check on the django install
|
# Run sanity check on the django install
|
||||||
manage(c, 'check')
|
manage(c, 'check')
|
||||||
|
|
||||||
pty = not disable_pty
|
pty = not disable_pty
|
||||||
|
|
||||||
# Run coverage tests
|
# Run coverage tests
|
||||||
manage(c, 'test --slowreport', pty=pty)
|
manage(c, f'test --slowreport {runtest}', pty=pty)
|
||||||
|
|
||||||
|
|
||||||
@task(help={'dev': 'Set up development environment at the end'})
|
@task(help={'dev': 'Set up development environment at the end'})
|
||||||
|
Loading…
Reference in New Issue
Block a user