Improve documentation regarding tests

This commit is contained in:
Matthias 2019-08-11 20:30:15 +02:00
parent b77c0d2813
commit c5d8499ad2
1 changed files with 23 additions and 0 deletions

View File

@ -17,6 +17,29 @@ Alternatively (if your system is not supported by the setup.sh script), follow t
This will install all required tools for development, including `pytest`, `flake8`, `mypy`, and `coveralls`.
### Tests
New code should be covered by basic unittests. Depending on the complexity of the feature, Reviewers may request more in-depth unittests.
If necessary, the Freqtrade team can assist and give guidance with writing good tests (however please don't expect anyone to write the tests for you).
#### Checking log content in tests
Freqtrade uses 2 main methods to check log content in tests, `log_has()` and `log_has_re()` (to check using regex, in case of dynamic log-messages).
These are available from `conftest.py` and can be imported in any test module.
A sample check looks as follows:
``` python
from freqtrade.tests.conftest import log_has, log_has_re
def test_method_to_test(caplog):
method_to_test()
assert log_has("This event happened", caplog)
# Check regex with trailing number ...
assert log_has_re(r"This dynamic event happened and produced \d+", caplog)
```
## Modules
### Dynamic Pairlist