1
- # uPyTest (MicroPytest) 🔬🐍✅
1
+ # uPyTest (MicroPytest) 🔬🐍✔️
2
2
3
3
A small and very limited module for very simple [ PyTest] ( https://pytest.org )
4
4
inspired tests to run in the [ MicroPython] ( https://micropython.org/ ) runtime
@@ -58,8 +58,8 @@ will be very different.
58
58
59
59
To create a test suite ensure your test functions are contained in modules
60
60
inside your test directory that start with ` test_ ` . If you want to change this
61
- pattern for matching test modules pass in a ` pattern ` argument as a string
62
- (whose default is currently ` pattern="test*.py" ` ).
61
+ pattern for matching test modules pass in a ` pattern ` argument as a string to
62
+ the ` upytest.run ` method (whose default is currently ` pattern="test*.py" ` ).
63
63
64
64
Inside the test module, test functions are identified by having ` test_ `
65
65
prepended to their name:
@@ -70,7 +70,7 @@ def test_something():
70
70
```
71
71
72
72
Just like PyTest, use the ` assert ` statement to verify test expectations. As
73
- shown above, a string following a comma is used as the value for the resulting
73
+ shown above, a string following a comma is used as the value for any resulting
74
74
` AssertionError ` should the ` assert ` fail.
75
75
76
76
Sometimes you need to skip existing tests. Simply use the ` skip ` decorator like
@@ -137,72 +137,104 @@ different sorts of information you may see:
137
137
138
138
```
139
139
Using conftest.py for global setup and teardown.
140
- Found 2 test module[s]. Running 18 test[s].
140
+ Found 2 test module[s]. Running 22 test[s].
141
141
142
- .S.FFFF...F..SF .FF
142
+ F.FF.SFF..FF.FS.FF. .FF
143
143
================================= FAILURES =================================
144
144
145
- ./tests/test_stuff.py::test_does_not_raise_exception
145
+ ./tests/test_with_setup_teardown.py::test_async_fails
146
+ Traceback (most recent call last):
147
+ File "upytest.py", line 89, in run
148
+ File "test_with_setup_teardown.py", line 51, in test_async_fails
149
+ AssertionError: This async test fails.
150
+
151
+
152
+ ./tests/test_with_setup_teardown.py::test_async_does_not_raise_exception
153
+ Traceback (most recent call last):
154
+ File "upytest.py", line 89, in run
155
+ File "test_with_setup_teardown.py", line 61, in test_async_does_not_raise_exception
156
+ File "upytest.py", line 238, in __exit__
157
+ AssertionError: Did not raise expected exception. Expected ValueError; but got None.
158
+
159
+
160
+ ./tests/test_with_setup_teardown.py::test_async_does_not_raise_expected_exception
161
+ Traceback (most recent call last):
162
+ File "upytest.py", line 89, in run
163
+ File "test_with_setup_teardown.py", line 66, in test_async_does_not_raise_expected_exception
164
+ File "upytest.py", line 238, in __exit__
165
+ AssertionError: Did not raise expected exception. Expected ValueError, AssertionError; but got TypeError.
166
+
167
+
168
+ ./tests/test_with_setup_teardown.py::test_does_not_raise_exception
146
169
Traceback (most recent call last):
147
170
File "upytest.py", line 91, in run
148
- File "test_stuff .py", line 24 , in test_does_not_raise_exception
149
- File "upytest.py", line 229 , in __exit__
150
- AssertionError: Did not raise expected exception.
171
+ File "test_with_setup_teardown .py", line 33 , in test_does_not_raise_exception
172
+ File "upytest.py", line 238 , in __exit__
173
+ AssertionError: Did not raise expected exception. Expected ValueError; but got None.
151
174
152
175
153
- ./tests/test_stuff .py::test_fails
176
+ ./tests/test_with_setup_teardown .py::test_does_not_raise_expected_exception
154
177
Traceback (most recent call last):
155
178
File "upytest.py", line 91, in run
156
- File "test_stuff.py", line 14, in test_fails
157
- AssertionError: This test fails
179
+ File "test_with_setup_teardown.py", line 38, in test_does_not_raise_expected_exception
180
+ File "upytest.py", line 238, in __exit__
181
+ AssertionError: Did not raise expected exception. Expected ValueError, AssertionError; but got TypeError.
158
182
159
183
160
- ./tests/test_stuff .py::test_async_fails
184
+ ./tests/test_with_setup_teardown .py::test_fails
161
185
Traceback (most recent call last):
162
- File "upytest.py", line 89 , in run
163
- File "test_stuff .py", line 37 , in test_async_fails
164
- AssertionError: This async test fails.
186
+ File "upytest.py", line 91 , in run
187
+ File "test_with_setup_teardown .py", line 23 , in test_fails
188
+ AssertionError: This test fails.
165
189
166
190
167
- ./tests/test_stuff.py::test_async_does_not_raise_exception
191
+ ./tests/test_stuff.py::test_async_does_not_raise_expected_exception
168
192
Traceback (most recent call last):
169
193
File "upytest.py", line 89, in run
170
- File "test_stuff.py", line 47 , in test_async_does_not_raise_exception
171
- File "upytest.py", line 229 , in __exit__
172
- AssertionError: Did not raise expected exception.
194
+ File "test_stuff.py", line 57 , in test_async_does_not_raise_expected_exception
195
+ File "upytest.py", line 238 , in __exit__
196
+ AssertionError: Did not raise expected exception. Expected ValueError, AssertionError; but got TypeError.
173
197
174
198
175
- ./tests/test_with_setup_teardown .py::test_async_does_not_raise_exception
199
+ ./tests/test_stuff .py::test_async_fails
176
200
Traceback (most recent call last):
177
201
File "upytest.py", line 89, in run
178
- File "test_with_setup_teardown.py", line 56, in test_async_does_not_raise_exception
179
- File "upytest.py", line 229, in __exit__
180
- AssertionError: Did not raise expected exception.
202
+ File "test_stuff.py", line 42, in test_async_fails
203
+ AssertionError: This async test fails.
181
204
182
205
183
- ./tests/test_with_setup_teardown .py::test_does_not_raise_exception
206
+ ./tests/test_stuff .py::test_does_not_raise_exception
184
207
Traceback (most recent call last):
185
208
File "upytest.py", line 91, in run
186
- File "test_with_setup_teardown .py", line 33 , in test_does_not_raise_exception
187
- File "upytest.py", line 229 , in __exit__
188
- AssertionError: Did not raise expected exception.
209
+ File "test_stuff .py", line 24 , in test_does_not_raise_exception
210
+ File "upytest.py", line 238 , in __exit__
211
+ AssertionError: Did not raise expected exception. Expected ValueError; but got None.
189
212
190
213
191
- ./tests/test_with_setup_teardown.py::test_async_fails
214
+ ./tests/test_stuff.py::test_does_not_raise_expected_exception
215
+ Traceback (most recent call last):
216
+ File "upytest.py", line 91, in run
217
+ File "test_stuff.py", line 29, in test_does_not_raise_expected_exception
218
+ File "upytest.py", line 238, in __exit__
219
+ AssertionError: Did not raise expected exception. Expected ValueError, AssertionError; but got TypeError.
220
+
221
+
222
+ ./tests/test_stuff.py::test_async_does_not_raise_exception
192
223
Traceback (most recent call last):
193
224
File "upytest.py", line 89, in run
194
- File "test_with_setup_teardown.py", line 46, in test_async_fails
195
- AssertionError: This async test fails.
225
+ File "test_stuff.py", line 52, in test_async_does_not_raise_exception
226
+ File "upytest.py", line 238, in __exit__
227
+ AssertionError: Did not raise expected exception. Expected ValueError; but got None.
196
228
197
229
198
- ./tests/test_with_setup_teardown .py::test_fails
230
+ ./tests/test_stuff .py::test_fails
199
231
Traceback (most recent call last):
200
232
File "upytest.py", line 91, in run
201
- File "test_with_setup_teardown .py", line 23 , in test_fails
202
- AssertionError: This test fails.
233
+ File "test_stuff .py", line 14 , in test_fails
234
+ AssertionError: This test fails
203
235
204
236
========================= short test summary info ==========================
205
- 8 failed, 2 skipped, 8 passed in 0.00 seconds
237
+ 12 failed, 2 skipped, 8 passed in 0.01 seconds
206
238
```
207
239
208
240
## Developer setup
0 commit comments