1HATCH-TEST(1) User Commands HATCH-TEST(1)
2
3
4
6 hatch test – Runs tests
7
9 hatch test [OPTIONS] [PACKAGE]
10
12 Runs tests using pytest, optionally checking coverage.
13
14 The path is derived in the following order:
15
16 1. The optional argument, which should be the name of a package
17 that was installed via hatch install -l or pip install -e.
18
19 2. The --local flag.
20
21 3. The option --path, which can be a relative or absolute path.
22
23 4. The current directory.
24
25 If the path points to a package, it should have a tests directory.
26
27 If a project is detected but there is no dedicated virtual env, it will
28 be created and any dev requirements will be installed in it.
29
31 -l, --local
32 Shortcut to select the only available local (editable) package.
33 If there are multiple, an error will be raised.
34
35 -p, --path TEXT
36 A relative or absolute path to a project or test directory.
37
38 -c, --cov
39 Computes, then outputs coverage after testing.
40
41 -m, --merge
42 If --cov, coverage will run using --parallel-mode and combine
43 the results.
44
45 -ta, --test-args TEXT
46 Pass through to pytest, overriding defaults.
47
48 Example:
49 hatch test -ta "-k test_core.py -vv"
50
51 -ca, --cov-args TEXT
52 Pass through to coverage run, overriding defaults.
53
54 Example:
55 hatch test -ca "--timid --pylib"
56
57 -g, --global
58 Uses the pytest and coverage shipped with Hatch instead of envi‐
59 ronment-aware modules. This is useful if you just want to run a
60 quick test without installing these again in a virtual env.
61 Keep in mind these will be the Python 3 versions.
62
63 -nd, --no-detect
64 Does not run the tests inside a project’s dedicated virtual env.
65
66 -h, --help
67 Show a help message and exit.
68
70 $ git clone https://github.com/ofek/privy && cd privy
71 $ hatch test -c
72 ========================= test session starts ==========================
73 platform linux -- Python 3.5.2, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
74 rootdir: /home/ofek/privy, inifile:
75 plugins: xdist-1.20.0, mock-1.6.2, httpbin-0.0.7, forked-0.2, cov-2.5.1
76 collected 10 items
77
78 tests/test_privy.py ..........
79 ====================== 10 passed in 4.34 seconds =======================
80
81 Tests completed, checking coverage...
82 .B Name Stmts Miss Branch BrPart Cover Missing
83 -----------------------------------------------------------------
84 privy/__init__.py 1 0 0 0 100%
85 privy/core.py 30 0 0 0 100%
86 privy/utils.py 13 0 4 0 100%
87 tests/__init__.py 0 0 0 0 100%
88 tests/test_privy.py 57 0 0 0 100%
89 -----------------------------------------------------------------
90 TOTAL 101 0 4 0 100%
91
93 hatch(1)
94
95 hatch-build(1), hatch-clean(1), hatch-conda(1), hatch-config(1),
96 hatch-env(1), hatch-grow(1), hatch-init(1), hatch-install(1),
97 hatch-new(1), hatch-pypath(1), hatch-python(1), hatch-release(1),
98 hatch-shed(1), hatch-shell(1), hatch-uninstall(1), hatch-update(1)
99
100
101
102 Feburary 2022 HATCH-TEST(1)