@@ -69,11 +69,12 @@ Given you have the following project structure:
6969│ ├── image.jpg
7070│ └── image.png
7171├── tests1/
72- │ ├── data/
73- │ │ ├── data1.txt
74- │ │ └── data2.txt
75- │ └── test_something_else.py
76- └── test_something.py
72+ │ └── test_something.py
73+ └── tests2/
74+ ├── data/
75+ │ ├── data1.txt
76+ │ └── data2.txt
77+ └── test_something_else.py
7778```
7879
7980### 1. Load file data — ` @load `
@@ -103,22 +104,22 @@ def test_something2(file_path, data):
103104```
104105
105106``` shell
106- $ pytest test_something.py -v
107+ $ pytest tests1/ test_something.py -v
107108================================ test session starts =================================
108109< snip>
109110collected 2 items
110111
111- tests /test_something.py::test_something1[data1.json] PASSED [ 50%]
112- tests /test_something.py::test_something2[data2.txt] PASSED [100%]
112+ tests1 /test_something.py::test_something1[data1.json] PASSED [ 50%]
113+ tests1 /test_something.py::test_something2[data2.txt] PASSED [100%]
113114
114115================================= 2 passed in 0.01s ==================================
115116```
116117
117118> [ !NOTE]
118- > If both ` ./test_something.py ` and ` ./tests1 /test_something_else.py ` happen to have the above same loader definitions,
119- > the first test function will load ` ./data/data1.json ` for both test files, and the second test function will load
120- > ` data2.txt ` from each test file's ** nearest** ` data ` directory. This ensures that each test file loads data from its
121- > nearest data directory.
119+ > If both ` ./tests1/ test_something.py ` and ` ./tests2 /test_something_else.py ` happen to have the above same loader
120+ > definitions, the first test function will load ` ./data/data1.json ` for both test files, and the second test function
121+ > will load ` data2.txt ` from each test file's ** nearest** ` data ` directory. This ensures that each test file loads data
122+ > from its nearest data directory.
122123> This behavior applies to all loaders.
123124
124125
@@ -150,16 +151,16 @@ def test_something2(file_path, data):
150151```
151152
152153``` shell
153- $ pytest test_something.py -v
154+ $ pytest tests1/ test_something.py -v
154155================================ test session starts =================================
155156< snip>
156157collected 5 items
157158
158- tests /test_something.py::test_something1[data1.json:part1] PASSED [ 20%]
159- tests /test_something.py::test_something1[data1.json:part2] PASSED [ 40%]
160- tests /test_something.py::test_something2[data2.txt:part1] PASSED [ 60%]
161- tests /test_something.py::test_something2[data2.txt:part2] PASSED [ 80%]
162- tests /test_something.py::test_something2[data2.txt:part3] PASSED [100%]
159+ tests1 /test_something.py::test_something1[data1.json:part1] PASSED [ 20%]
160+ tests1 /test_something.py::test_something1[data1.json:part2] PASSED [ 40%]
161+ tests1 /test_something.py::test_something2[data2.txt:part1] PASSED [ 60%]
162+ tests1 /test_something.py::test_something2[data2.txt:part2] PASSED [ 80%]
163+ tests1 /test_something.py::test_something2[data2.txt:part3] PASSED [100%]
163164
164165================================= 5 passed in 0.01s ==================================
165166```
@@ -196,14 +197,14 @@ def test_something(data):
196197```
197198
198199``` shell
199- $ pytest test_something.py -v
200+ $ pytest tests1/ test_something.py -v
200201================================ test session starts =================================
201202< snip>
202203collected 3 items
203204
204- tests /test_something.py::test_something[image.gif] PASSED [ 33%]
205- tests /test_something.py::test_something[image.jpg] PASSED [ 66%]
206- tests /test_something.py::test_something[image.png] PASSED [100%]
205+ tests1 /test_something.py::test_something[image.gif] PASSED [ 33%]
206+ tests1 /test_something.py::test_something[image.jpg] PASSED [ 66%]
207+ tests1 /test_something.py::test_something[image.png] PASSED [100%]
207208
208209================================= 3 passed in 0.01s ==================================
209210```
0 commit comments