Debian Codegraph @

tests/u/README.md

raw
1 # Unit Tests
2
3 This directory contains Cylc unit tests.
4
5 ## How To Run These Tests
6
7 ```console
8 $ pytest tests/u
9 $ pytest tests/u -n 5 # run up to 5 tests in parallel
10 $ pytest tests/u --dist=no -n0 # turn off xdist (allows --pdb etc)
11 ```
12
13 ## What Are Unit Tests
14
15 Unit tests test the smallest possible units of functionality, typically
16 methods or functions.
17
18 The interaction of components is mitigated by mocking input objects.
19
20 ## Guidelines
21
22 Don't write integration tests here:
23
24 * If your test requires any of the fixtures in the integration tests
25 then it is an integration test.
26 * If your test sees logic flow through multiple modules it's not a unit test.
27 * If you are constructing computationally expensive objects it's unlikely
28 to be a unit test.
29
30 ## Doctests
31
32 Doctests are Python interactive shell examples embedded in the docstrings of
33 functions/methods, that can provide some level of unit testing. E.g.
34 ```python
35 def factorial(n):
36 """
37 Example:
38 >>> factorial(7)
39 5040
40 """
41 ```
42
43 To run doctests:
44 ```console
45 $ pytest cylc/flow
46 ```