Compare commits
800 Commits
8.0.0.dev0
...
8.3.0.dev0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9eecdc7dae | ||
|
|
79ca819e59 | ||
|
|
835765c9d3 | ||
|
|
7e7503c0b0 | ||
|
|
882c4da2f3 | ||
|
|
2e8fb9f140 | ||
|
|
acf2971f46 | ||
|
|
3c77aec1da | ||
|
|
d217d68cde | ||
|
|
530be28575 | ||
|
|
d208c1d4a5 | ||
|
|
80ca255d42 | ||
|
|
1a332802ff | ||
|
|
93c2cdf6d6 | ||
|
|
4eb8b6d525 | ||
|
|
fafab1dbfd | ||
|
|
5cffef7f07 | ||
|
|
a830a3e98d | ||
|
|
1d322ffb48 | ||
|
|
63d985c6d3 | ||
|
|
3617ef1c79 | ||
|
|
58136c5376 | ||
|
|
042625957a | ||
|
|
6fb474a3eb | ||
|
|
ff806b239e | ||
|
|
ad95d59d61 | ||
|
|
48b6d18834 | ||
|
|
58844247f7 | ||
|
|
b56b294f54 | ||
|
|
6e248818b9 | ||
|
|
0644e467fb | ||
|
|
5f6e825a26 | ||
|
|
089116bdff | ||
|
|
1f001cd105 | ||
|
|
99890636bf | ||
|
|
17fc20af78 | ||
|
|
1ca59dfd6b | ||
|
|
e06c337bd8 | ||
|
|
a02cc0ad1b | ||
|
|
74f05648d5 | ||
|
|
f75dd87eb7 | ||
|
|
5acc3f86ac | ||
|
|
4e3dd21506 | ||
|
|
2e65f4e3ac | ||
|
|
cc588d1a1a | ||
|
|
b63bea9523 | ||
|
|
a10ddad774 | ||
|
|
1188ea2608 | ||
|
|
aa5324560b | ||
|
|
381593ccf0 | ||
|
|
9d6b5f8772 | ||
|
|
44895289c7 | ||
|
|
1125296b53 | ||
|
|
bd9b62161a | ||
|
|
e64efd8653 | ||
|
|
2dd58e827e | ||
|
|
12e061e2e8 | ||
|
|
5d345f6d7f | ||
|
|
2cba2237cd | ||
|
|
e7b048e92d | ||
|
|
4a8cefbf64 | ||
|
|
909759de2d | ||
|
|
85ff5d1b54 | ||
|
|
cfc4cf074e | ||
|
|
aeae91e27d | ||
|
|
3eb16b34be | ||
|
|
c650e3a94f | ||
|
|
470edc5884 | ||
|
|
07a08028de | ||
|
|
42d3960fea | ||
|
|
e7bf216516 | ||
|
|
532782a228 | ||
|
|
bf8b088bbe | ||
|
|
027464975f | ||
|
|
6be5c9d88c | ||
|
|
2607fe8b47 | ||
|
|
2e69f31444 | ||
|
|
70c11582aa | ||
|
|
c203f1615c | ||
|
|
bec0e9caf8 | ||
|
|
2e5da5d2fb | ||
|
|
c0532dda18 | ||
|
|
14437788f0 | ||
|
|
7eaaf370bb | ||
|
|
6c9e107681 | ||
|
|
122b43439c | ||
|
|
a29ea1bc32 | ||
|
|
0a442a9599 | ||
|
|
520ff29c07 | ||
|
|
b777b05c0e | ||
|
|
b90da34a86 | ||
|
|
0dc0360351 | ||
|
|
140c777590 | ||
|
|
774f0c44e6 | ||
|
|
006058f1f9 | ||
|
|
437eb86edd | ||
|
|
9033d4d3ff | ||
|
|
2ccc73be9a | ||
|
|
ff551b7685 | ||
|
|
f5de111357 | ||
|
|
71671f60b5 | ||
|
|
a9d1f55a0f | ||
|
|
83887c066b | ||
|
|
4a8bd5f2e2 | ||
|
|
51595d9000 | ||
|
|
1a5e0eb71d | ||
|
|
221097517b | ||
|
|
dacee1f11d | ||
|
|
303cd0d48a | ||
|
|
86945f9a1f | ||
|
|
03e54712dd | ||
|
|
18c0e5075f | ||
|
|
6ee02a3e6c | ||
|
|
0951cbc6e4 | ||
|
|
37b3401091 | ||
|
|
13558b9f53 | ||
|
|
23bdc643c9 | ||
|
|
71849cc05c | ||
|
|
e410705561 | ||
|
|
00043f7f10 | ||
|
|
f4e10251a4 | ||
|
|
43492f5707 | ||
|
|
82fe28dae4 | ||
|
|
5e2ee7175c | ||
|
|
89ee4493cc | ||
|
|
8248946a55 | ||
|
|
434282e17f | ||
|
|
d6134bc21e | ||
|
|
aac720abc9 | ||
|
|
111c0d910e | ||
|
|
199d4e2b73 | ||
|
|
5746b8e696 | ||
|
|
c85fce39b6 | ||
|
|
067daf9f7d | ||
|
|
5867426455 | ||
|
|
4dea18308b | ||
|
|
7524e60d8f | ||
|
|
dcf01fd39a | ||
|
|
300ceb435e | ||
|
|
887e251abb | ||
|
|
6ed005161d | ||
|
|
31026a2df2 | ||
|
|
f20e32c982 | ||
|
|
1612d4e393 | ||
|
|
5e0d11746c | ||
|
|
b6bf58abe8 | ||
|
|
ff4c3b2873 | ||
|
|
4db5e53709 | ||
|
|
c967d508d6 | ||
|
|
bd45ccd2ca | ||
|
|
c83c1c4bda | ||
|
|
686f9e0720 | ||
|
|
98b008ff6c | ||
|
|
73edefdd64 | ||
|
|
ffd727e9d6 | ||
|
|
b6eb985d55 | ||
|
|
affc652f1c | ||
|
|
7460b1aa31 | ||
|
|
84bd31de64 | ||
|
|
a2a9aa6cde | ||
|
|
c09f74619b | ||
|
|
b510adf9ef | ||
|
|
93cd7ba857 | ||
|
|
8d9b95dcdb | ||
|
|
ad651ddfce | ||
|
|
00d9640abc | ||
|
|
010ce2ab0f | ||
|
|
1640f2e454 | ||
|
|
59e9a58cc9 | ||
|
|
691d8fcafb | ||
|
|
c5c729e27a | ||
|
|
9bea1be215 | ||
|
|
2007cf6296 | ||
|
|
79def57cc6 | ||
|
|
8a410d0ba6 | ||
|
|
a37cff3ca8 | ||
|
|
95f21f96cc | ||
|
|
998fee1679 | ||
|
|
40011b838b | ||
|
|
b37696703b | ||
|
|
abf6a60567 | ||
|
|
52da8dd66c | ||
|
|
cefb3e2277 | ||
|
|
5f241f388b | ||
|
|
aebeb33137 | ||
|
|
9f13d41d7b | ||
|
|
984478109f | ||
|
|
22b541e4eb | ||
|
|
fbe18fc7a9 | ||
|
|
9b838f491f | ||
|
|
6ef0cf150a | ||
|
|
0475b1c925 | ||
|
|
dcf9da92be | ||
|
|
8e56795b77 | ||
|
|
718cd40015 | ||
|
|
288201b8f5 | ||
|
|
c6313a06fb | ||
|
|
5d7a5a9343 | ||
|
|
cbb5c82c39 | ||
|
|
acafd003aa | ||
|
|
46e6fb12c7 | ||
|
|
fe7907d78c | ||
|
|
5bb1363435 | ||
|
|
ca84327f15 | ||
|
|
3b798e5422 | ||
|
|
526b971221 | ||
|
|
23dfb52974 | ||
|
|
7da04c963f | ||
|
|
b922270ce7 | ||
|
|
1180348303 | ||
|
|
7690a0ddf1 | ||
|
|
29a5f94428 | ||
|
|
ea57c40c43 | ||
|
|
a182e10b06 | ||
|
|
d1ee6d154f | ||
|
|
d02618d173 | ||
|
|
9454fc38d3 | ||
|
|
101328aba5 | ||
|
|
42785cca44 | ||
|
|
6c0b6c2f92 | ||
|
|
9cd14b4ffb | ||
|
|
4c894f20a1 | ||
|
|
6e5008f19f | ||
|
|
b9d02c5b53 | ||
|
|
d1095426c1 | ||
|
|
757778f5f6 | ||
|
|
404d31a942 | ||
|
|
0d91539614 | ||
|
|
835e8032f4 | ||
|
|
c76ea72331 | ||
|
|
dab1583ce1 | ||
|
|
411c2cbf9d | ||
|
|
c3583dee0b | ||
|
|
a1d99e4bdd | ||
|
|
aaa9ca7327 | ||
|
|
29094983d7 | ||
|
|
b8e56557c6 | ||
|
|
304ccb4ad7 | ||
|
|
90634a6060 | ||
|
|
ccbae95ad4 | ||
|
|
cd9b241047 | ||
|
|
5c67cb2cf5 | ||
|
|
2fc7926bae | ||
|
|
79de84941a | ||
|
|
0d1f4c63fa | ||
|
|
2d4e27daf2 | ||
|
|
2e50788b6d | ||
|
|
3101c026b9 | ||
|
|
e193a263c7 | ||
|
|
4eb246d4e1 | ||
|
|
41ff3584d7 | ||
|
|
b62d4b3527 | ||
|
|
e7bab63537 | ||
|
|
52fba25ff9 | ||
|
|
fcb818b73c | ||
|
|
7eef4619d5 | ||
|
|
e28f35c296 | ||
|
|
b28bb01c4e | ||
|
|
3ba4095400 | ||
|
|
99e8129ba3 | ||
|
|
20b18f0f9a | ||
|
|
cb5f738858 | ||
|
|
5be64c31cb | ||
|
|
233ab89f13 | ||
|
|
8967c527ff | ||
|
|
180a16a344 | ||
|
|
514376fe29 | ||
|
|
bdfc5c80d8 | ||
|
|
9ef905e7a0 | ||
|
|
4588653b24 | ||
|
|
046f64751b | ||
|
|
4546d5445a | ||
|
|
de161f8791 | ||
|
|
3be2a9d655 | ||
|
|
e885013c6b | ||
|
|
8b54596639 | ||
|
|
899a6cf2ce | ||
|
|
407d984142 | ||
|
|
21bec6cfbe | ||
|
|
cb57bf50b1 | ||
|
|
c0dfc45186 | ||
|
|
5855f65d0f | ||
|
|
14d3707818 | ||
|
|
8853a57532 | ||
|
|
878af85aef | ||
|
|
e7b43b2121 | ||
|
|
d0f427aec4 | ||
|
|
c6da0d20d2 | ||
|
|
a164ed6400 | ||
|
|
eb9013d42c | ||
|
|
ac2cd72e5f | ||
|
|
bca4bb0738 | ||
|
|
2a77f8d88b | ||
|
|
d972957303 | ||
|
|
44bf7a2ec0 | ||
|
|
5ab8972bb5 | ||
|
|
21440521fa | ||
|
|
79ae968131 | ||
|
|
c3fc717ff7 | ||
|
|
d71ef04f11 | ||
|
|
111ad26f71 | ||
|
|
2178ee86d7 | ||
|
|
a6dd90a414 | ||
|
|
676f38d04a | ||
|
|
212c55218b | ||
|
|
34fafe4c6b | ||
|
|
eefc9d47fc | ||
|
|
7fd561e4ba | ||
|
|
da9749cd97 | ||
|
|
ca5bbd0a9f | ||
|
|
5cd0535395 | ||
|
|
0f5aa5a7d2 | ||
|
|
9ea2e0a79f | ||
|
|
0f5ecd83c4 | ||
|
|
6b9bba2edb | ||
|
|
6e9f566d79 | ||
|
|
a6708b9254 | ||
|
|
e895c9d38c | ||
|
|
c973ccb622 | ||
|
|
dd1447cfe5 | ||
|
|
9ad8b9fc36 | ||
|
|
348e6de102 | ||
|
|
9af6d46371 | ||
|
|
e1074f9c3d | ||
|
|
6e74601466 | ||
|
|
3acbdc2f79 | ||
|
|
707642ad35 | ||
|
|
2413d1b214 | ||
|
|
2bb0eca347 | ||
|
|
1c9d6834fd | ||
|
|
c6ed86453f | ||
|
|
e403bbf1a9 | ||
|
|
a7c2549321 | ||
|
|
d65bcd9a3b | ||
|
|
06dbd3c21c | ||
|
|
1b78de4e21 | ||
|
|
82fda31e99 | ||
|
|
5645fa45fb | ||
|
|
5bd5b80afd | ||
|
|
bd58c09500 | ||
|
|
996e45d66a | ||
|
|
c7d85c5dc6 | ||
|
|
b1c430820f | ||
|
|
35a3863b15 | ||
|
|
368fa2c03e | ||
|
|
372c17e228 | ||
|
|
c4a356eaee | ||
|
|
2270cab1c2 | ||
|
|
956d0e5e9d | ||
|
|
7bc8385924 | ||
|
|
9b7e10a3c0 | ||
|
|
913d93debb | ||
|
|
97dfc3429e | ||
|
|
992d0f082f | ||
|
|
b968f63ca5 | ||
|
|
c8792bd080 | ||
|
|
3234c79ee5 | ||
|
|
851b72f289 | ||
|
|
1d7349d18c | ||
|
|
5747a6c06e | ||
|
|
13eacdad8a | ||
|
|
a616adf3ae | ||
|
|
685e52ec30 | ||
|
|
7b4ab8134e | ||
|
|
c2a4a8d518 | ||
|
|
ac96256272 | ||
|
|
d38193646d | ||
|
|
cd07177906 | ||
|
|
6321b74fae | ||
|
|
5aa289e478 | ||
|
|
12b9bd5801 | ||
|
|
f017df443a | ||
|
|
1ba07450e4 | ||
|
|
215f4d1fab | ||
|
|
6c89f9261c | ||
|
|
a98f02d423 | ||
|
|
effc2b0529 | ||
|
|
2c5c97b6d1 | ||
|
|
cb5a42c836 | ||
|
|
0f18a7fe5e | ||
|
|
0591569b4b | ||
|
|
477959ef7d | ||
|
|
4147c92b21 | ||
|
|
10fbb2325f | ||
|
|
1f8b39ed32 | ||
|
|
f4e7b0d6e0 | ||
|
|
f13724e2e3 | ||
|
|
a53984a55b | ||
|
|
d3c7ba310c | ||
|
|
6bec880283 | ||
|
|
a1b6b7473b | ||
|
|
3701d1218b | ||
|
|
d220880924 | ||
|
|
640f84a5aa | ||
|
|
460c38915d | ||
|
|
a71a95b54c | ||
|
|
acd445a3f3 | ||
|
|
c7ee55993b | ||
|
|
b9855b244d | ||
|
|
1e5aab1b2b | ||
|
|
f93c0fc34e | ||
|
|
52db918a27 | ||
|
|
54a0ee02ea | ||
|
|
88ae27da08 | ||
|
|
e06a3d02f8 | ||
|
|
75f292d9df | ||
|
|
581762fcba | ||
|
|
803b190a17 | ||
|
|
283a746dad | ||
|
|
64b5b665cf | ||
|
|
6aa35f772f | ||
|
|
03b24e5b30 | ||
|
|
7541c5a999 | ||
|
|
27f7cee238 | ||
|
|
047ba83dab | ||
|
|
2b86d2bddc | ||
|
|
dfc910ee90 | ||
|
|
ab307b3402 | ||
|
|
8ce76c307e | ||
|
|
ef8bf82a78 | ||
|
|
e1c66ab0ad | ||
|
|
385796ba49 | ||
|
|
f411c8d6d7 | ||
|
|
c7fcb3f281 | ||
|
|
c1339628d6 | ||
|
|
397769c45e | ||
|
|
5381cd083f | ||
|
|
0ae02e2165 | ||
|
|
2aa8743bbe | ||
|
|
ee91d095f6 | ||
|
|
f76af423b0 | ||
|
|
4918883336 | ||
|
|
d1675646f2 | ||
|
|
9056db4de5 | ||
|
|
a5ee9f2ecd | ||
|
|
a536f49d91 | ||
|
|
cd269f0e6d | ||
|
|
b8118ab70d | ||
|
|
022f1b4de5 | ||
|
|
db8c6f1da8 | ||
|
|
3e14c4b3c4 | ||
|
|
714ce2e872 | ||
|
|
5689d806cf | ||
|
|
0f6c17ca83 | ||
|
|
ef699f8c17 | ||
|
|
81c06b3955 | ||
|
|
968510b6aa | ||
|
|
5782aab017 | ||
|
|
ad1bccdead | ||
|
|
172bf89ad1 | ||
|
|
88c3546006 | ||
|
|
50607297f4 | ||
|
|
767f08cecd | ||
|
|
e5a448cd5f | ||
|
|
64e72b79f6 | ||
|
|
c4375f14b8 | ||
|
|
2d1710e0e9 | ||
|
|
fe8cda051b | ||
|
|
df963fded7 | ||
|
|
6053bb8d6a | ||
|
|
03220f7c9e | ||
|
|
85e0f676c5 | ||
|
|
e0d5754d5d | ||
|
|
acab13fcc9 | ||
|
|
a42530a09d | ||
|
|
fdb8bbf154 | ||
|
|
53d7b5ed3e | ||
|
|
19934b2b0c | ||
|
|
2953120003 | ||
|
|
5fae5ef73e | ||
|
|
66f2f20eff | ||
|
|
2322668344 | ||
|
|
eb6ad08e5d | ||
|
|
0916191827 | ||
|
|
476bab84f7 | ||
|
|
9dc1fc4523 | ||
|
|
80442ae2f2 | ||
|
|
223e030604 | ||
|
|
1eca302c4d | ||
|
|
970d11cf34 | ||
|
|
d4c56c72d8 | ||
|
|
442b09ed9f | ||
|
|
9417aeb2d8 | ||
|
|
99f7738810 | ||
|
|
7c7bdf4574 | ||
|
|
6fe43912be | ||
|
|
e701df5eb6 | ||
|
|
92cd7950e6 | ||
|
|
ef2216c21b | ||
|
|
01a248d2a9 | ||
|
|
1a7641cf88 | ||
|
|
70f03dbc3e | ||
|
|
1e02797d15 | ||
|
|
13e5ef0102 | ||
|
|
1ea10c20df | ||
|
|
8fb7e8b31e | ||
|
|
0d74a1c8a0 | ||
|
|
730c7ca0b1 | ||
|
|
4ecf313604 | ||
|
|
d0a09d8627 | ||
|
|
738ae2da9d | ||
|
|
7156a97f9a | ||
|
|
ed8701a57f | ||
|
|
247436819a | ||
|
|
c1728948ac | ||
|
|
dcd8b145d9 | ||
|
|
c7e9b22f37 | ||
|
|
fbe3e29a55 | ||
|
|
667b9fd7fd | ||
|
|
38f7c1e346 | ||
|
|
bcd9664370 | ||
|
|
7e69ce7449 | ||
|
|
395bbae8a2 | ||
|
|
ee53433542 | ||
|
|
304ab8495e | ||
|
|
40e9abd66b | ||
|
|
cac1eed0ea | ||
|
|
cdddd6d695 | ||
|
|
dd68f9c95a | ||
|
|
3ab70cd561 | ||
|
|
23825f2983 | ||
|
|
fb3a46dd8a | ||
|
|
3d6d93d0c2 | ||
|
|
2401d76655 | ||
|
|
af9b1dcc24 | ||
|
|
696859fc43 | ||
|
|
e966dcd93c | ||
|
|
54623f0f33 | ||
|
|
9bbfe995ee | ||
|
|
d015bc1b8f | ||
|
|
b73b4c464c | ||
|
|
1a16bac131 | ||
|
|
81192ca85f | ||
|
|
486a9ed057 | ||
|
|
4ae102c003 | ||
|
|
c614590ec9 | ||
|
|
d2b214220f | ||
|
|
a38ad254ef | ||
|
|
9f22d3281c | ||
|
|
9a58e6283d | ||
|
|
8bac8d7807 | ||
|
|
5e081162df | ||
|
|
8062743f6b | ||
|
|
8b7f94f145 | ||
|
|
5ace48ca5b | ||
|
|
e7caaa0b3e | ||
|
|
a47fcb4873 | ||
|
|
ab8f5ce7f4 | ||
|
|
f43a8db618 | ||
|
|
6c2feb75d2 | ||
|
|
fcb8e73288 | ||
|
|
241f2a890e | ||
|
|
39f9306357 | ||
|
|
e0d04bdfab | ||
|
|
1949b09fd3 | ||
|
|
3d1c52f203 | ||
|
|
a60c23c3d8 | ||
|
|
24a6ee1ffd | ||
|
|
e2acc1a99b | ||
|
|
71f265f1f3 | ||
|
|
7259e8db98 | ||
|
|
dd7beb39d6 | ||
|
|
6ad9499c9c | ||
|
|
2ed2e9208d | ||
|
|
ab63ebb3dc | ||
|
|
b3a981d385 | ||
|
|
48b0395648 | ||
|
|
9c11275553 | ||
|
|
e5c81fa41a | ||
|
|
0a06db0729 | ||
|
|
5936a79fdb | ||
|
|
28ccf476b9 | ||
|
|
333e4eba6b | ||
|
|
e787d2ed48 | ||
|
|
f6b6478868 | ||
|
|
3ce63bc768 | ||
|
|
faa8f2ea08 | ||
|
|
194a782e38 | ||
|
|
bc71561ad9 | ||
|
|
574e0f45d9 | ||
|
|
b8906b29a7 | ||
|
|
d2b5177dd6 | ||
|
|
65c01f531b | ||
|
|
82bd63d318 | ||
|
|
d4872f5df7 | ||
|
|
8d815ca55b | ||
|
|
8032d21271 | ||
|
|
9c8937b480 | ||
|
|
0d8b87f161 | ||
|
|
65c73a09e7 | ||
|
|
917ce9aa01 | ||
|
|
4e3a0874df | ||
|
|
ba0da81f88 | ||
|
|
f08782d8d0 | ||
|
|
5b528bd131 | ||
|
|
e4794b26b2 | ||
|
|
ab6cae2126 | ||
|
|
afb8d66e42 | ||
|
|
76ba7db6ce | ||
|
|
941b203c94 | ||
|
|
19d6b12b2a | ||
|
|
17e8f2b3fc | ||
|
|
ff23347f1f | ||
|
|
00fedcc439 | ||
|
|
77f7f59b2a | ||
|
|
7500fe44b2 | ||
|
|
23b899f31f | ||
|
|
43d1398fc7 | ||
|
|
03832fa31e | ||
|
|
8f36fd5454 | ||
|
|
cada6c105a | ||
|
|
3f446b68fd | ||
|
|
050f402816 | ||
|
|
d1722d5c18 | ||
|
|
4deb38b2ed | ||
|
|
370eacd3ca | ||
|
|
010e1742d8 | ||
|
|
6e5f10b28f | ||
|
|
dd5ae0c3b8 | ||
|
|
fc653d0d12 | ||
|
|
a357c7abc8 | ||
|
|
61133ba83d | ||
|
|
049eec8474 | ||
|
|
37bb186175 | ||
|
|
3cb3cd1a08 | ||
|
|
7a625481da | ||
|
|
0ddfdfcc04 | ||
|
|
87bfc83aa0 | ||
|
|
ebd571bb18 | ||
|
|
176d728b7b | ||
|
|
d4fb6ac9f7 | ||
|
|
15fadd8c5c | ||
|
|
73d754bd74 | ||
|
|
10056865d2 | ||
|
|
1827d8d5f9 | ||
|
|
9e164fc4fe | ||
|
|
c0cf822ca1 | ||
|
|
ec1053cc16 | ||
|
|
d2dc8a70b5 | ||
|
|
b9cb87d862 | ||
|
|
e938580257 | ||
|
|
47c0fc3d78 | ||
|
|
556e075d23 | ||
|
|
3ad3fc6b8f | ||
|
|
09b78737a5 | ||
|
|
b2186e2455 | ||
|
|
18bc6c9a0e | ||
|
|
24c9aa6c30 | ||
|
|
9c67b7aeb6 | ||
|
|
1cc58ed67f | ||
|
|
84a342e27c | ||
|
|
e8a8a5f320 | ||
|
|
1c04a92503 | ||
|
|
cc0adf6bf3 | ||
|
|
b8b74331b4 | ||
|
|
4797deab99 | ||
|
|
c9163402e0 | ||
|
|
01ac13a77d | ||
|
|
485c555812 | ||
|
|
a21fb87a90 | ||
|
|
c754da10d2 | ||
|
|
71e627aa8f | ||
|
|
d3552ef4c0 | ||
|
|
448563caaa | ||
|
|
e8aa906e06 | ||
|
|
12054a4972 | ||
|
|
430ad145c1 | ||
|
|
13e2b00258 | ||
|
|
4e42421ebf | ||
|
|
161ba87300 | ||
|
|
f2b6040e9e | ||
|
|
e3247834e2 | ||
|
|
0b4a557087 | ||
|
|
ffdcce67f4 | ||
|
|
1ded74739b | ||
|
|
497a1d798a | ||
|
|
1de0923e83 | ||
|
|
7c30f674c5 | ||
|
|
396bfbf30b | ||
|
|
02ba39bfcd | ||
|
|
29010d23a6 | ||
|
|
de1f6f58ba | ||
|
|
cfda801ebf | ||
|
|
c5262b0c42 | ||
|
|
ff6e110161 | ||
|
|
0e0ed2af95 | ||
|
|
a3fbf24389 | ||
|
|
bf451d47a1 | ||
|
|
578fbe3dfd | ||
|
|
a668719626 | ||
|
|
04e0db7e48 | ||
|
|
32f480814c | ||
|
|
40ed678885 | ||
|
|
fb55615d5e | ||
|
|
9d0ddb4625 | ||
|
|
01f38aca44 | ||
|
|
78d81ef865 | ||
|
|
b41acaea12 | ||
|
|
7008385253 | ||
|
|
b25a3adff5 | ||
|
|
ecfab4dc8b | ||
|
|
2c80de532f | ||
|
|
7967b2e710 | ||
|
|
f1c9570a0e | ||
|
|
b20e7f6d0c | ||
|
|
b91d5a3112 | ||
|
|
4e75bff71a | ||
|
|
99ab8ae884 | ||
|
|
782cacf86b | ||
|
|
a3b4220d76 | ||
|
|
fd7a4d2429 | ||
|
|
b73ec8e5d1 | ||
|
|
d790e96765 | ||
|
|
d4265448a5 | ||
|
|
db37e34613 | ||
|
|
c5b13099e6 | ||
|
|
97ed533f63 | ||
|
|
f5a9aa0b84 | ||
|
|
901316b3f4 | ||
|
|
b81003f6fb | ||
|
|
ddd773ecb1 | ||
|
|
44604f49cd | ||
|
|
2203897086 | ||
|
|
119cec0279 | ||
|
|
b5bc53e441 | ||
|
|
084d756ae6 | ||
|
|
d7dbadbffc | ||
|
|
cb732f7f49 | ||
|
|
7775e494b1 | ||
|
|
1f5058e972 | ||
|
|
6baf9f2d31 | ||
|
|
c4876c7106 | ||
|
|
6badb6f01e | ||
|
|
4517af1e28 | ||
|
|
3d0dedb5ec | ||
|
|
7b7bd304aa | ||
|
|
2706271f66 | ||
|
|
8ac3c645fa | ||
|
|
18e87c9831 | ||
|
|
6995257cf4 | ||
|
|
bea56b30af | ||
|
|
b847084224 | ||
|
|
024e62e6d2 | ||
|
|
f9410fddcd | ||
|
|
561f1a993b | ||
|
|
b77d0deaf5 | ||
|
|
2f7415cfbc | ||
|
|
ba60649680 | ||
|
|
679bd6f2ed | ||
|
|
a50ea1b8e7 | ||
|
|
0353a94cd1 | ||
|
|
0311fc3384 | ||
|
|
7fdc8391e2 | ||
|
|
15524f34d2 | ||
|
|
2d48171e88 | ||
|
|
7022fb455d | ||
|
|
a1b37022af | ||
|
|
9279ea2882 | ||
|
|
165fbbd12a | ||
|
|
f617bab0a2 | ||
|
|
f4e3b4ad98 | ||
|
|
81cfb3fc87 | ||
|
|
dd5f3773d9 | ||
|
|
e132d6488f | ||
|
|
4719d998d8 | ||
|
|
5332656906 | ||
|
|
a14fc10cac | ||
|
|
05d7e60904 | ||
|
|
4ebb2b94c2 | ||
|
|
9859c110cc | ||
|
|
5eaf8207eb | ||
|
|
518ca37cae | ||
|
|
45f1a462d5 | ||
|
|
4cd95eeabf | ||
|
|
1306b84241 | ||
|
|
fe51121f39 | ||
|
|
c8b1790ee7 | ||
|
|
2870157234 | ||
|
|
1b7896f83d | ||
|
|
a4a189ad99 | ||
|
|
bd88a6412d | ||
|
|
264e7ac327 | ||
|
|
a2feb6bd00 | ||
|
|
246ceb84bd | ||
|
|
2fd160110c | ||
|
|
2998b596b4 | ||
|
|
7f73722c4a | ||
|
|
f7542f6292 | ||
|
|
0de2aa93f0 | ||
|
|
7759a9d3c2 | ||
|
|
d86df89a92 | ||
|
|
24fd292878 | ||
|
|
a1b10b552a | ||
|
|
aa9cc7e8b4 | ||
|
|
5c286d19d8 | ||
|
|
faac197fcf | ||
|
|
5227279c15 | ||
|
|
a7e0ae2455 | ||
|
|
12efc58479 | ||
|
|
3f71680ac0 |
@@ -23,6 +23,11 @@ afc607cfd81458d4e4f3b1f3cf8cc931b933907e
|
||||
5f95dce95602921a70bfbc7d8de2f7712c5e4505
|
||||
# ran pyupgrade-docs again
|
||||
75d0b899bbb56d6849e9d69d83a9426ed3f43f8b
|
||||
|
||||
# move argument parser to own file
|
||||
c9df77cbd6a365dcb73c39618e4842711817e871
|
||||
# Replace reorder-python-imports by isort due to black incompatibility (#11896)
|
||||
8b54596639f41dfac070030ef20394b9001fe63c
|
||||
# Run blacken-docs with black's 2024's style
|
||||
4546d5445aaefe6a03957db028c263521dfb5c4b
|
||||
# Migration to ruff / ruff format
|
||||
4588653b2497ed25976b7aaff225b889fb476756
|
||||
2
.github/workflows/backport.yml
vendored
2
.github/workflows/backport.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
|
||||
89
.github/workflows/deploy.yml
vendored
89
.github/workflows/deploy.yml
vendored
@@ -1,60 +1,101 @@
|
||||
name: deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
# These tags are protected, see:
|
||||
# https://github.com/pytest-dev/pytest/settings/tag_protection
|
||||
- "[0-9]+.[0-9]+.[0-9]+"
|
||||
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Release version'
|
||||
required: true
|
||||
default: '1.2.3'
|
||||
|
||||
|
||||
# Set permissions at the job level.
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
|
||||
deploy:
|
||||
if: github.repository == 'pytest-dev/pytest'
|
||||
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Build and Check Package
|
||||
uses: hynek/build-and-inspect-python-package@v1.5
|
||||
uses: hynek/build-and-inspect-python-package@v2.4.0
|
||||
|
||||
deploy:
|
||||
if: github.repository == 'pytest-dev/pytest'
|
||||
needs: [package]
|
||||
runs-on: ubuntu-latest
|
||||
environment: deploy
|
||||
timeout-minutes: 30
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Download Package
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
|
||||
- name: Publish package to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
uses: pypa/gh-action-pypi-publish@v1.8.14
|
||||
|
||||
- name: Push tag
|
||||
run: |
|
||||
git config user.name "pytest bot"
|
||||
git config user.email "pytestbot@gmail.com"
|
||||
git tag --annotate --message=v${{ github.event.inputs.version }} ${{ github.event.inputs.version }} ${{ github.sha }}
|
||||
git push origin ${{ github.event.inputs.version }}
|
||||
|
||||
release-notes:
|
||||
|
||||
# todo: generate the content in the build job
|
||||
# the goal being of using a github action script to push the release data
|
||||
# after success instead of creating a complete python/tox env
|
||||
needs: [deploy]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
password: ${{ secrets.pypi_token }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Download Package
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.7"
|
||||
python-version: "3.11"
|
||||
|
||||
- name: Install tox
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install --upgrade tox
|
||||
|
||||
- name: Publish GitHub release notes
|
||||
env:
|
||||
GH_RELEASE_NOTES_TOKEN: ${{ github.token }}
|
||||
- name: Generate release notes
|
||||
run: |
|
||||
sudo apt-get install pandoc
|
||||
tox -e publish-gh-release-notes
|
||||
tox -e generate-gh-release-notes -- ${{ github.event.inputs.version }} scripts/latest-release-notes.md
|
||||
|
||||
- name: Publish GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
body_path: scripts/latest-release-notes.md
|
||||
files: dist/*
|
||||
tag_name: ${{ github.event.inputs.version }}
|
||||
|
||||
4
.github/workflows/prepare-release-pr.yml
vendored
4
.github/workflows/prepare-release-pr.yml
vendored
@@ -27,12 +27,12 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.8"
|
||||
|
||||
|
||||
6
.github/workflows/stale.yml
vendored
6
.github/workflows/stale.yml
vendored
@@ -10,14 +10,14 @@ jobs:
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- uses: actions/stale@v8
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
debug-only: false
|
||||
days-before-issue-stale: 14
|
||||
days-before-issue-close: 7
|
||||
only-labels: "status: needs information"
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: "This issue is stale because it has been open for 14 days with no activity."
|
||||
close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
|
||||
stale-issue-message: "This issue is stale because it has the `status: needs information` label and requested follow-up information was not provided for 14 days."
|
||||
close-issue-message: "This issue was closed because it has the `status: needs information` label and follow-up information has not been provided for 7 days since being marked as stale."
|
||||
days-before-pr-stale: -1
|
||||
days-before-pr-close: -1
|
||||
|
||||
100
.github/workflows/test.yml
vendored
100
.github/workflows/test.yml
vendored
@@ -27,7 +27,19 @@ concurrency:
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Build and Check Package
|
||||
uses: hynek/build-and-inspect-python-package@v2.4.0
|
||||
|
||||
build:
|
||||
needs: [package]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 45
|
||||
permissions:
|
||||
@@ -37,48 +49,41 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
name: [
|
||||
"windows-py37",
|
||||
"windows-py37-pluggy",
|
||||
"windows-py38",
|
||||
"windows-py38-pluggy",
|
||||
"windows-py39",
|
||||
"windows-py310",
|
||||
"windows-py311",
|
||||
"windows-py312",
|
||||
|
||||
"ubuntu-py37",
|
||||
"ubuntu-py37-pluggy",
|
||||
"ubuntu-py37-freeze",
|
||||
"ubuntu-py38",
|
||||
"ubuntu-py38-pluggy",
|
||||
"ubuntu-py38-freeze",
|
||||
"ubuntu-py39",
|
||||
"ubuntu-py310",
|
||||
"ubuntu-py311",
|
||||
"ubuntu-py312",
|
||||
"ubuntu-pypy3",
|
||||
|
||||
"macos-py37",
|
||||
"macos-py38",
|
||||
"macos-py39",
|
||||
"macos-py310",
|
||||
"macos-py312",
|
||||
|
||||
"docs",
|
||||
"doctesting",
|
||||
"plugins",
|
||||
]
|
||||
|
||||
include:
|
||||
- name: "windows-py37"
|
||||
python: "3.7"
|
||||
os: windows-latest
|
||||
tox_env: "py37-numpy"
|
||||
- name: "windows-py37-pluggy"
|
||||
python: "3.7"
|
||||
os: windows-latest
|
||||
tox_env: "py37-pluggymain-pylib-xdist"
|
||||
- name: "windows-py38"
|
||||
python: "3.8"
|
||||
os: windows-latest
|
||||
tox_env: "py38-unittestextras"
|
||||
use_coverage: true
|
||||
- name: "windows-py38-pluggy"
|
||||
python: "3.8"
|
||||
os: windows-latest
|
||||
tox_env: "py38-pluggymain-pylib-xdist"
|
||||
- name: "windows-py39"
|
||||
python: "3.9"
|
||||
os: windows-latest
|
||||
@@ -96,23 +101,19 @@ jobs:
|
||||
os: windows-latest
|
||||
tox_env: "py312"
|
||||
|
||||
- name: "ubuntu-py37"
|
||||
python: "3.7"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py37-lsof-numpy-pexpect"
|
||||
use_coverage: true
|
||||
- name: "ubuntu-py37-pluggy"
|
||||
python: "3.7"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py37-pluggymain-pylib-xdist"
|
||||
- name: "ubuntu-py37-freeze"
|
||||
python: "3.7"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py37-freeze"
|
||||
- name: "ubuntu-py38"
|
||||
python: "3.8"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py38-xdist"
|
||||
tox_env: "py38-lsof-numpy-pexpect"
|
||||
use_coverage: true
|
||||
- name: "ubuntu-py38-pluggy"
|
||||
python: "3.8"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py38-pluggymain-pylib-xdist"
|
||||
- name: "ubuntu-py38-freeze"
|
||||
python: "3.8"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py38-freeze"
|
||||
- name: "ubuntu-py39"
|
||||
python: "3.9"
|
||||
os: ubuntu-latest
|
||||
@@ -132,14 +133,14 @@ jobs:
|
||||
tox_env: "py312"
|
||||
use_coverage: true
|
||||
- name: "ubuntu-pypy3"
|
||||
python: "pypy-3.7"
|
||||
python: "pypy-3.8"
|
||||
os: ubuntu-latest
|
||||
tox_env: "pypy3-xdist"
|
||||
|
||||
- name: "macos-py37"
|
||||
python: "3.7"
|
||||
- name: "macos-py38"
|
||||
python: "3.8"
|
||||
os: macos-latest
|
||||
tox_env: "py37-xdist"
|
||||
tox_env: "py38-xdist"
|
||||
- name: "macos-py39"
|
||||
python: "3.9"
|
||||
os: macos-latest
|
||||
@@ -155,28 +156,30 @@ jobs:
|
||||
tox_env: "py312-xdist"
|
||||
|
||||
- name: "plugins"
|
||||
python: "3.9"
|
||||
python: "3.12"
|
||||
os: ubuntu-latest
|
||||
tox_env: "plugins"
|
||||
|
||||
- name: "docs"
|
||||
python: "3.7"
|
||||
os: ubuntu-latest
|
||||
tox_env: "docs"
|
||||
- name: "doctesting"
|
||||
python: "3.7"
|
||||
python: "3.8"
|
||||
os: ubuntu-latest
|
||||
tox_env: "doctesting"
|
||||
use_coverage: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Download Package
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
|
||||
- name: Set up Python ${{ matrix.python }}
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
check-latest: ${{ endsWith(matrix.python, '-dev') }}
|
||||
@@ -188,11 +191,13 @@ jobs:
|
||||
|
||||
- name: Test without coverage
|
||||
if: "! matrix.use_coverage"
|
||||
run: "tox -e ${{ matrix.tox_env }}"
|
||||
shell: bash
|
||||
run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`
|
||||
|
||||
- name: Test with coverage
|
||||
if: "matrix.use_coverage"
|
||||
run: "tox -e ${{ matrix.tox_env }}-coverage"
|
||||
shell: bash
|
||||
run: tox run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz`
|
||||
|
||||
- name: Generate coverage report
|
||||
if: "matrix.use_coverage"
|
||||
@@ -200,16 +205,9 @@ jobs:
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
if: "matrix.use_coverage"
|
||||
uses: codecov/codecov-action@v3
|
||||
uses: codecov/codecov-action@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage.xml
|
||||
verbose: true
|
||||
|
||||
check-package:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build and Check Package
|
||||
uses: hynek/build-and-inspect-python-package@v1.5
|
||||
|
||||
18
.github/workflows/update-plugin-list.yml
vendored
18
.github/workflows/update-plugin-list.yml
vendored
@@ -20,25 +20,33 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.8
|
||||
python-version: "3.11"
|
||||
cache: pip
|
||||
- name: requests-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pytest-plugin-list/
|
||||
key: plugins-http-cache-${{ github.run_id }} # Can use time based key as well
|
||||
restore-keys: plugins-http-cache-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install packaging requests tabulate[widechars] tqdm
|
||||
pip install packaging requests tabulate[widechars] tqdm requests-cache platformdirs
|
||||
|
||||
|
||||
- name: Update Plugin List
|
||||
run: python scripts/update-plugin-list.py
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
|
||||
uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83
|
||||
with:
|
||||
commit-message: '[automated] Update plugin list'
|
||||
author: 'pytest bot <pytestbot@users.noreply.github.com>'
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -51,6 +51,7 @@ coverage.xml
|
||||
.settings
|
||||
.vscode
|
||||
__pycache__/
|
||||
.python-version
|
||||
|
||||
# generated by pip
|
||||
pip-wheel-metadata/
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 23.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
args: [--safe, --quiet]
|
||||
- repo: https://github.com/asottile/blacken-docs
|
||||
rev: 1.14.0
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
additional_dependencies: [black==23.1.0]
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: "v0.4.1"
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: ["--fix"]
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
rev: v4.6.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
@@ -20,58 +16,47 @@ repos:
|
||||
- id: debug-statements
|
||||
exclude: _pytest/(debugging|hookspec).py
|
||||
language_version: python3
|
||||
- repo: https://github.com/PyCQA/autoflake
|
||||
rev: v2.1.1
|
||||
- repo: https://github.com/adamchainz/blacken-docs
|
||||
rev: 1.16.0
|
||||
hooks:
|
||||
- id: autoflake
|
||||
name: autoflake
|
||||
args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"]
|
||||
language: python
|
||||
files: \.py$
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 6.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
language_version: python3
|
||||
additional_dependencies:
|
||||
- flake8-typing-imports==1.12.0
|
||||
- flake8-docstrings==1.5.0
|
||||
- repo: https://github.com/asottile/reorder-python-imports
|
||||
rev: v3.10.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
args: ['--application-directories=.:src', --py37-plus]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.7.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py37-plus]
|
||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
args: ["--max-py-version=3.12", "--include-version-classifiers"]
|
||||
- id: blacken-docs
|
||||
additional_dependencies: [black==24.1.1]
|
||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||
rev: v1.10.0
|
||||
hooks:
|
||||
- id: python-use-type-annotations
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.3.0
|
||||
rev: v1.9.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
files: ^(src/|testing/)
|
||||
files: ^(src/|testing/|scripts/)
|
||||
args: []
|
||||
additional_dependencies:
|
||||
- iniconfig>=1.1.0
|
||||
- attrs>=19.2.0
|
||||
- pluggy>=1.5.0
|
||||
- packaging
|
||||
- tomli
|
||||
- types-pkg_resources
|
||||
- types-tabulate
|
||||
# for mypy running on python>=3.11 since exceptiongroup is only a dependency
|
||||
# on <3.11
|
||||
- exceptiongroup>=1.0.0rc8
|
||||
- repo: https://github.com/tox-dev/pyproject-fmt
|
||||
rev: "1.8.0"
|
||||
hooks:
|
||||
- id: pyproject-fmt
|
||||
# https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version
|
||||
additional_dependencies: ["tox>=4.9"]
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pylint
|
||||
name: pylint
|
||||
entry: pylint
|
||||
language: system
|
||||
types: [python]
|
||||
args: ["-rn", "-sn", "--fail-on=I"]
|
||||
stages: [manual]
|
||||
- id: rst
|
||||
name: rst
|
||||
entry: rst-lint --encoding utf-8
|
||||
|
||||
@@ -9,6 +9,10 @@ python:
|
||||
path: .
|
||||
- requirements: doc/en/requirements.txt
|
||||
|
||||
sphinx:
|
||||
configuration: doc/en/conf.py
|
||||
fail_on_warning: true
|
||||
|
||||
build:
|
||||
os: ubuntu-20.04
|
||||
tools:
|
||||
|
||||
43
AUTHORS
43
AUTHORS
@@ -11,6 +11,7 @@ Adam Johnson
|
||||
Adam Stewart
|
||||
Adam Uhlir
|
||||
Ahn Ki-Wook
|
||||
Akhilesh Ramakrishnan
|
||||
Akiomi Kamakura
|
||||
Alan Velasco
|
||||
Alessio Izzo
|
||||
@@ -47,15 +48,20 @@ Ariel Pillemer
|
||||
Armin Rigo
|
||||
Aron Coyle
|
||||
Aron Curzon
|
||||
Arthur Richard
|
||||
Ashish Kurmi
|
||||
Aviral Verma
|
||||
Aviv Palivoda
|
||||
Babak Keyvani
|
||||
Barney Gale
|
||||
Ben Brown
|
||||
Ben Gartner
|
||||
Ben Leith
|
||||
Ben Webb
|
||||
Benjamin Peterson
|
||||
Benjamin Schubert
|
||||
Bernard Pratz
|
||||
Bo Wu
|
||||
Bob Ippolito
|
||||
Brian Dorsey
|
||||
Brian Larsen
|
||||
@@ -88,12 +94,14 @@ Christopher Dignam
|
||||
Christopher Gilling
|
||||
Claire Cecil
|
||||
Claudio Madotto
|
||||
Clément M.T. Robert
|
||||
CrazyMerlyn
|
||||
Cristian Vera
|
||||
Cyrus Maden
|
||||
Damian Skrzypczak
|
||||
Daniel Grana
|
||||
Daniel Hahler
|
||||
Daniel Miller
|
||||
Daniel Nuri
|
||||
Daniel Sánchez Castelló
|
||||
Daniel Valenzuela Zenteno
|
||||
@@ -111,6 +119,7 @@ Daw-Ran Liou
|
||||
Debi Mishra
|
||||
Denis Kirisov
|
||||
Denivy Braiam Rück
|
||||
Dheeraj C K
|
||||
Dhiren Serai
|
||||
Diego Russo
|
||||
Dmitry Dygalo
|
||||
@@ -121,6 +130,8 @@ Edison Gustavo Muenz
|
||||
Edoardo Batini
|
||||
Edson Tadeu M. Manoel
|
||||
Eduardo Schettino
|
||||
Edward Haigh
|
||||
Eero Vaher
|
||||
Eli Boyarski
|
||||
Elizaveta Shashkova
|
||||
Éloi Rivard
|
||||
@@ -128,18 +139,23 @@ Endre Galaczi
|
||||
Eric Hunsberger
|
||||
Eric Liu
|
||||
Eric Siegerman
|
||||
Eric Yuan
|
||||
Erik Aronesty
|
||||
Erik Hasse
|
||||
Erik M. Bray
|
||||
Evan Kepner
|
||||
Evgeny Seliverstov
|
||||
Fabian Sturm
|
||||
Fabien Zarifian
|
||||
Fabio Zadrozny
|
||||
faph
|
||||
Felix Hofstätter
|
||||
Felix Nieuwenhuizen
|
||||
Feng Ma
|
||||
Florian Bruhin
|
||||
Florian Dahlitz
|
||||
Floris Bruynooghe
|
||||
Fraser Stark
|
||||
Gabriel Landau
|
||||
Gabriel Reis
|
||||
Garvit Shubham
|
||||
@@ -166,6 +182,8 @@ Ian Bicking
|
||||
Ian Lesperance
|
||||
Ilya Konstantinov
|
||||
Ionuț Turturică
|
||||
Isaac Virshup
|
||||
Israel Fruchter
|
||||
Itxaso Aizpurua
|
||||
Iwan Briquemont
|
||||
Jaap Broekhuizen
|
||||
@@ -181,6 +199,7 @@ Javier Romero
|
||||
Jeff Rackauckas
|
||||
Jeff Widman
|
||||
Jenni Rinker
|
||||
Jens Tröger
|
||||
John Eddie Ayson
|
||||
John Litborn
|
||||
John Towler
|
||||
@@ -219,6 +238,7 @@ Kyle Altendorf
|
||||
Lawrence Mitchell
|
||||
Lee Kamentsky
|
||||
Lev Maximov
|
||||
Levon Saldamli
|
||||
Lewis Cowles
|
||||
Llandy Riveron Del Risco
|
||||
Loic Esteve
|
||||
@@ -229,9 +249,11 @@ Maho
|
||||
Maik Figura
|
||||
Mandeep Bhutani
|
||||
Manuel Krebber
|
||||
Marc Mueller
|
||||
Marc Schlaich
|
||||
Marcelo Duarte Trevisani
|
||||
Marcin Bachry
|
||||
Marc Bresson
|
||||
Marco Gorelli
|
||||
Mark Abramowitz
|
||||
Mark Dickinson
|
||||
@@ -256,15 +278,20 @@ Michael Goerz
|
||||
Michael Krebs
|
||||
Michael Seifert
|
||||
Michal Wajszczuk
|
||||
Michał Górny
|
||||
Michał Zięba
|
||||
Mickey Pashov
|
||||
Mihai Capotă
|
||||
Mihail Milushev
|
||||
Mike Hoyle (hoylemd)
|
||||
Mike Lundy
|
||||
Milan Lesnek
|
||||
Miro Hrončok
|
||||
mrbean-bremen
|
||||
Nathaniel Compton
|
||||
Nathaniel Waisbrot
|
||||
Ned Batchelder
|
||||
Neil Martin
|
||||
Neven Mundar
|
||||
Nicholas Devenish
|
||||
Nicholas Murphy
|
||||
@@ -282,6 +309,7 @@ Ondřej Súkup
|
||||
Oscar Benjamin
|
||||
Parth Patel
|
||||
Patrick Hayes
|
||||
Patrick Lannigan
|
||||
Paul Müller
|
||||
Paul Reece
|
||||
Pauli Virtanen
|
||||
@@ -294,6 +322,7 @@ Pierre Sassoulas
|
||||
Pieter Mulder
|
||||
Piotr Banaszkiewicz
|
||||
Piotr Helm
|
||||
Poulami Sau
|
||||
Prakhar Gurunani
|
||||
Prashant Anand
|
||||
Prashant Sharma
|
||||
@@ -310,6 +339,7 @@ Raphael Pierzina
|
||||
Rafal Semik
|
||||
Raquel Alegre
|
||||
Ravi Chandra
|
||||
Reagan Lee
|
||||
Robert Holt
|
||||
Roberto Aldera
|
||||
Roberto Polli
|
||||
@@ -320,25 +350,33 @@ Ronny Pfannschmidt
|
||||
Ross Lawley
|
||||
Ruaridh Williamson
|
||||
Russel Winder
|
||||
Russell Martin
|
||||
Ryan Puddephatt
|
||||
Ryan Wooden
|
||||
Sadra Barikbin
|
||||
Saiprasad Kale
|
||||
Samuel Colvin
|
||||
Samuel Dion-Girardeau
|
||||
Samuel Searles-Bryant
|
||||
Samuel Therrien (Avasam)
|
||||
Samuele Pedroni
|
||||
Sanket Duthade
|
||||
Sankt Petersbug
|
||||
Saravanan Padmanaban
|
||||
Sean Malloy
|
||||
Segev Finer
|
||||
Serhii Mozghovyi
|
||||
Seth Junot
|
||||
Shantanu Jain
|
||||
Sharad Nair
|
||||
Shubham Adep
|
||||
Simon Blanchard
|
||||
Simon Gomizelj
|
||||
Simon Holesch
|
||||
Simon Kerr
|
||||
Skylar Downes
|
||||
Srinivas Reddy Thatiparthy
|
||||
Stefaan Lippens
|
||||
Stefan Farmbauer
|
||||
Stefan Scherfke
|
||||
Stefan Zimmermann
|
||||
@@ -352,6 +390,7 @@ Tadek Teleżyński
|
||||
Takafumi Arakaki
|
||||
Taneli Hukkinen
|
||||
Tanvi Mehta
|
||||
Tanya Agarwal
|
||||
Tarcisio Fischer
|
||||
Tareq Alayan
|
||||
Tatiana Ovary
|
||||
@@ -370,7 +409,9 @@ Tomer Keren
|
||||
Tony Narlock
|
||||
Tor Colvin
|
||||
Trevor Bekolay
|
||||
Tushar Sadhwani
|
||||
Tyler Goodlet
|
||||
Tyler Smart
|
||||
Tzu-ping Chung
|
||||
Vasily Kuznetsov
|
||||
Victor Maryama
|
||||
@@ -384,6 +425,7 @@ Vivaan Verma
|
||||
Vlad Dragos
|
||||
Vlad Radziuk
|
||||
Vladyslav Rachek
|
||||
Volodymyr Kochetkov
|
||||
Volodymyr Piskun
|
||||
Wei Lin
|
||||
Wil Cooley
|
||||
@@ -394,6 +436,7 @@ Xixi Zhao
|
||||
Xuan Luong
|
||||
Xuecong Liao
|
||||
Yannick Péroux
|
||||
Yao Xiao
|
||||
Yoav Caspi
|
||||
Yuliang Shao
|
||||
Yusuke Kadowaki
|
||||
|
||||
@@ -50,7 +50,7 @@ Fix bugs
|
||||
--------
|
||||
|
||||
Look through the `GitHub issues for bugs <https://github.com/pytest-dev/pytest/labels/type:%20bug>`_.
|
||||
See also the `"status: easy" issues <https://github.com/pytest-dev/pytest/labels/status%3A%20easy>`_
|
||||
See also the `"good first issue" issues <https://github.com/pytest-dev/pytest/labels/good%20first%20issue>`_
|
||||
that are friendly to new contributors.
|
||||
|
||||
:ref:`Talk <contact>` to developers to find out how you can fix specific bugs. To indicate that you are going
|
||||
@@ -197,11 +197,12 @@ Short version
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
#. Fork the repository.
|
||||
#. Fetch tags from upstream if necessary (if you cloned only main `git fetch --tags https://github.com/pytest-dev/pytest`).
|
||||
#. Enable and install `pre-commit <https://pre-commit.com>`_ to ensure style-guides and code checks are followed.
|
||||
#. Follow **PEP-8** for naming and `black <https://github.com/psf/black>`_ for formatting.
|
||||
#. Follow `PEP-8 <https://www.python.org/dev/peps/pep-0008/>`_ for naming.
|
||||
#. Tests are run using ``tox``::
|
||||
|
||||
tox -e linting,py37
|
||||
tox -e linting,py39
|
||||
|
||||
The test environments above are usually enough to cover most cases locally.
|
||||
|
||||
@@ -236,6 +237,7 @@ Here is a simple overview, with pytest-specific bits:
|
||||
|
||||
$ git clone git@github.com:YOUR_GITHUB_USERNAME/pytest.git
|
||||
$ cd pytest
|
||||
$ git fetch --tags https://github.com/pytest-dev/pytest
|
||||
# now, create your own branch off "main":
|
||||
|
||||
$ git checkout -b your-bugfix-branch-name main
|
||||
@@ -272,35 +274,35 @@ Here is a simple overview, with pytest-specific bits:
|
||||
|
||||
#. Run all the tests
|
||||
|
||||
You need to have Python 3.7 available in your system. Now
|
||||
You need to have Python 3.8 or later available in your system. Now
|
||||
running tests is as simple as issuing this command::
|
||||
|
||||
$ tox -e linting,py37
|
||||
$ tox -e linting,py39
|
||||
|
||||
This command will run tests via the "tox" tool against Python 3.7
|
||||
This command will run tests via the "tox" tool against Python 3.9
|
||||
and also perform "lint" coding-style checks.
|
||||
|
||||
#. You can now edit your local working copy and run the tests again as necessary. Please follow PEP-8 for naming.
|
||||
#. You can now edit your local working copy and run the tests again as necessary. Please follow `PEP-8 <https://www.python.org/dev/peps/pep-0008/>`_ for naming.
|
||||
|
||||
You can pass different options to ``tox``. For example, to run tests on Python 3.7 and pass options to pytest
|
||||
You can pass different options to ``tox``. For example, to run tests on Python 3.9 and pass options to pytest
|
||||
(e.g. enter pdb on failure) to pytest you can do::
|
||||
|
||||
$ tox -e py37 -- --pdb
|
||||
$ tox -e py39 -- --pdb
|
||||
|
||||
Or to only run tests in a particular test module on Python 3.7::
|
||||
Or to only run tests in a particular test module on Python 3.9::
|
||||
|
||||
$ tox -e py37 -- testing/test_config.py
|
||||
$ tox -e py39 -- testing/test_config.py
|
||||
|
||||
|
||||
When committing, ``pre-commit`` will re-format the files if necessary.
|
||||
|
||||
#. If instead of using ``tox`` you prefer to run the tests directly, then we suggest to create a virtual environment and use
|
||||
an editable install with the ``testing`` extra::
|
||||
an editable install with the ``dev`` extra::
|
||||
|
||||
$ python3 -m venv .venv
|
||||
$ source .venv/bin/activate # Linux
|
||||
$ .venv/Scripts/activate.bat # Windows
|
||||
$ pip install -e ".[testing]"
|
||||
$ pip install -e ".[dev]"
|
||||
|
||||
Afterwards, you can edit the files and run pytest normally::
|
||||
|
||||
|
||||
13
README.rst
13
README.rst
@@ -20,16 +20,13 @@
|
||||
:target: https://codecov.io/gh/pytest-dev/pytest
|
||||
:alt: Code coverage Status
|
||||
|
||||
.. image:: https://github.com/pytest-dev/pytest/workflows/test/badge.svg
|
||||
.. image:: https://github.com/pytest-dev/pytest/actions/workflows/test.yml/badge.svg
|
||||
:target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Atest
|
||||
|
||||
.. image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest/main.svg
|
||||
:target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest/main
|
||||
:alt: pre-commit.ci status
|
||||
|
||||
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
||||
:target: https://github.com/psf/black
|
||||
|
||||
.. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
|
||||
:target: https://www.codetriage.com/pytest-dev/pytest
|
||||
|
||||
@@ -97,12 +94,12 @@ Features
|
||||
- `Modular fixtures <https://docs.pytest.org/en/stable/explanation/fixtures.html>`_ for
|
||||
managing small or parametrized long-lived test resources
|
||||
|
||||
- Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
|
||||
`nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box
|
||||
- Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial)
|
||||
test suites out of the box
|
||||
|
||||
- Python 3.7+ or PyPy3
|
||||
- Python 3.8+ or PyPy3
|
||||
|
||||
- Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
|
||||
- Rich plugin architecture, with over 1300+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
|
||||
|
||||
|
||||
Documentation
|
||||
|
||||
@@ -133,14 +133,12 @@ Releasing
|
||||
|
||||
Both automatic and manual processes described above follow the same steps from this point onward.
|
||||
|
||||
#. After all tests pass and the PR has been approved, tag the release commit
|
||||
in the ``release-MAJOR.MINOR.PATCH`` branch and push it. This will publish to PyPI::
|
||||
#. After all tests pass and the PR has been approved, trigger the ``deploy`` job
|
||||
in https://github.com/pytest-dev/pytest/actions/workflows/deploy.yml, using the ``release-MAJOR.MINOR.PATCH`` branch
|
||||
as source.
|
||||
|
||||
git fetch upstream
|
||||
git tag MAJOR.MINOR.PATCH upstream/release-MAJOR.MINOR.PATCH
|
||||
git push upstream MAJOR.MINOR.PATCH
|
||||
|
||||
Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
|
||||
This job will require approval from ``pytest-dev/core``, after which it will publish to PyPI
|
||||
and tag the repository.
|
||||
|
||||
#. Merge the PR. **Make sure it's not squash-merged**, so that the tagged commit ends up in the main branch.
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ members of the `contributors team`_ interested in receiving funding.
|
||||
|
||||
The current list of contributors receiving funding are:
|
||||
|
||||
* `@asottile`_
|
||||
* `@nicoddemus`_
|
||||
* `@The-Compiler`_
|
||||
* `@RonnyPfannschmidt`_
|
||||
|
||||
Contributors interested in receiving a part of the funds just need to submit a PR adding their
|
||||
name to the list. Contributors that want to stop receiving the funds should also submit a PR
|
||||
@@ -55,6 +55,6 @@ funds. Just drop a line to one of the `@pytest-dev/tidelift-admins`_ or use the
|
||||
.. _`@pytest-dev/tidelift-admins`: https://github.com/orgs/pytest-dev/teams/tidelift-admins/members
|
||||
.. _`agreement`: https://tidelift.com/docs/lifting/agreement
|
||||
|
||||
.. _`@asottile`: https://github.com/asottile
|
||||
.. _`@nicoddemus`: https://github.com/nicoddemus
|
||||
.. _`@The-Compiler`: https://github.com/The-Compiler
|
||||
.. _`@RonnyPfannschmidt`: https://github.com/RonnyPfannschmidt
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import cProfile
|
||||
import pytest # NOQA
|
||||
import pstats
|
||||
|
||||
import pytest # noqa: F401
|
||||
|
||||
script = sys.argv[1:] if len(sys.argv) > 1 else ["empty.py"]
|
||||
cProfile.run("pytest.cmdline.main(%r)" % script, "prof")
|
||||
p = pstats.Stats("prof")
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# FastFilesCompleter 0.7383 1.0760
|
||||
import timeit
|
||||
|
||||
|
||||
imports = [
|
||||
"from argcomplete.completers import FilesCompleter as completer",
|
||||
"from _pytest._argcomplete import FastFilesCompleter as completer",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
|
||||
|
||||
SKIP = True
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from unittest import TestCase # noqa: F401
|
||||
|
||||
|
||||
for i in range(15000):
|
||||
exec(
|
||||
f"""
|
||||
|
||||
@@ -14,7 +14,7 @@ Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
|
||||
``<ISSUE>`` is an issue number, and ``<TYPE>`` is one of:
|
||||
|
||||
* ``feature``: new user facing features, like new command-line options and new behavior.
|
||||
* ``improvement``: improvement of existing functionality, usually without requiring user intervention (for example, new fields being written in ``--junitxml``, improved colors in terminal, etc).
|
||||
* ``improvement``: improvement of existing functionality, usually without requiring user intervention (for example, new fields being written in ``--junit-xml``, improved colors in terminal, etc).
|
||||
* ``bugfix``: fixes a bug.
|
||||
* ``doc``: documentation improvement, like rewording an entire session or adding missing docs.
|
||||
* ``deprecation``: feature deprecation.
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="{{ pathto('search') }}" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel"
|
||||
placeholder="Search"/>
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="{{ _('Go') }}" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
<script>document.getElementById('searchbox').style.display = "block"</script>
|
||||
{%- endif %}
|
||||
|
||||
@@ -44,7 +44,7 @@ Partner projects, sign up here! (by 22 March)
|
||||
What does it mean to "adopt pytest"?
|
||||
-----------------------------------------
|
||||
|
||||
There can be many different definitions of "success". Pytest can run many nose_ and unittest_ tests by default, so using pytest as your testrunner may be possible from day 1. Job done, right?
|
||||
There can be many different definitions of "success". Pytest can run many unittest_ tests by default, so using pytest as your testrunner may be possible from day 1. Job done, right?
|
||||
|
||||
Progressive success might look like:
|
||||
|
||||
@@ -62,7 +62,6 @@ Progressive success might look like:
|
||||
|
||||
It may be after the month is up, the partner project decides that pytest is not right for it. That's okay - hopefully the pytest team will also learn something about its weaknesses or deficiencies.
|
||||
|
||||
.. _nose: nose.html
|
||||
.. _unittest: unittest.html
|
||||
.. _assert: assert.html
|
||||
.. _pycmd: https://bitbucket.org/hpk42/pycmd/overview
|
||||
|
||||
@@ -6,6 +6,19 @@ Release announcements
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
release-8.2.0
|
||||
release-8.1.2
|
||||
release-8.1.1
|
||||
release-8.1.0
|
||||
release-8.0.2
|
||||
release-8.0.1
|
||||
release-8.0.0
|
||||
release-8.0.0rc2
|
||||
release-8.0.0rc1
|
||||
release-7.4.4
|
||||
release-7.4.3
|
||||
release-7.4.2
|
||||
release-7.4.1
|
||||
release-7.4.0
|
||||
release-7.3.2
|
||||
release-7.3.1
|
||||
|
||||
20
doc/en/announce/release-7.4.1.rst
Normal file
20
doc/en/announce/release-7.4.1.rst
Normal file
@@ -0,0 +1,20 @@
|
||||
pytest-7.4.1
|
||||
=======================================
|
||||
|
||||
pytest 7.4.1 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Florian Bruhin
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
18
doc/en/announce/release-7.4.2.rst
Normal file
18
doc/en/announce/release-7.4.2.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
pytest-7.4.2
|
||||
=======================================
|
||||
|
||||
pytest 7.4.2 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
19
doc/en/announce/release-7.4.3.rst
Normal file
19
doc/en/announce/release-7.4.3.rst
Normal file
@@ -0,0 +1,19 @@
|
||||
pytest-7.4.3
|
||||
=======================================
|
||||
|
||||
pytest 7.4.3 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Marc Mueller
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
20
doc/en/announce/release-7.4.4.rst
Normal file
20
doc/en/announce/release-7.4.4.rst
Normal file
@@ -0,0 +1,20 @@
|
||||
pytest-7.4.4
|
||||
=======================================
|
||||
|
||||
pytest 7.4.4 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Ran Benita
|
||||
* Zac Hatfield-Dodds
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
26
doc/en/announce/release-8.0.0.rst
Normal file
26
doc/en/announce/release-8.0.0.rst
Normal file
@@ -0,0 +1,26 @@
|
||||
pytest-8.0.0
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.0.0 release!
|
||||
|
||||
This release contains new features, improvements, bug fixes, and breaking changes, so users
|
||||
are encouraged to take a look at the CHANGELOG carefully:
|
||||
|
||||
https://docs.pytest.org/en/stable/changelog.html
|
||||
|
||||
For complete documentation, please visit:
|
||||
|
||||
https://docs.pytest.org/en/stable/
|
||||
|
||||
As usual, you can upgrade from PyPI via:
|
||||
|
||||
pip install -U pytest
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
82
doc/en/announce/release-8.0.0rc1.rst
Normal file
82
doc/en/announce/release-8.0.0rc1.rst
Normal file
@@ -0,0 +1,82 @@
|
||||
pytest-8.0.0rc1
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.0.0rc1 release!
|
||||
|
||||
This release contains new features, improvements, bug fixes, and breaking changes, so users
|
||||
are encouraged to take a look at the CHANGELOG carefully:
|
||||
|
||||
https://docs.pytest.org/en/stable/changelog.html
|
||||
|
||||
For complete documentation, please visit:
|
||||
|
||||
https://docs.pytest.org/en/stable/
|
||||
|
||||
As usual, you can upgrade from PyPI via:
|
||||
|
||||
pip install -U pytest
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Akhilesh Ramakrishnan
|
||||
* Aleksandr Brodin
|
||||
* Anthony Sottile
|
||||
* Arthur Richard
|
||||
* Avasam
|
||||
* Benjamin Schubert
|
||||
* Bruno Oliveira
|
||||
* Carsten Grohmann
|
||||
* Cheukting
|
||||
* Chris Mahoney
|
||||
* Christoph Anton Mitterer
|
||||
* DetachHead
|
||||
* Erik Hasse
|
||||
* Florian Bruhin
|
||||
* Fraser Stark
|
||||
* Ha Pam
|
||||
* Hugo van Kemenade
|
||||
* Isaac Virshup
|
||||
* Israel Fruchter
|
||||
* Jens Tröger
|
||||
* Jon Parise
|
||||
* Kenny Y
|
||||
* Lesnek
|
||||
* Marc Mueller
|
||||
* Michał Górny
|
||||
* Mihail Milushev
|
||||
* Milan Lesnek
|
||||
* Miro Hrončok
|
||||
* Patrick Lannigan
|
||||
* Ran Benita
|
||||
* Reagan Lee
|
||||
* Ronny Pfannschmidt
|
||||
* Sadra Barikbin
|
||||
* Sean Malloy
|
||||
* Sean Patrick Malloy
|
||||
* Sharad Nair
|
||||
* Simon Blanchard
|
||||
* Sourabh Beniwal
|
||||
* Stefaan Lippens
|
||||
* Tanya Agarwal
|
||||
* Thomas Grainger
|
||||
* Tom Mortimer-Jones
|
||||
* Tushar Sadhwani
|
||||
* Tyler Smart
|
||||
* Uday Kumar
|
||||
* Warren Markham
|
||||
* WarrenTheRabbit
|
||||
* Zac Hatfield-Dodds
|
||||
* Ziad Kermadi
|
||||
* akhilramkee
|
||||
* antosikv
|
||||
* bowugit
|
||||
* mickeypash
|
||||
* neilmartin2000
|
||||
* pomponchik
|
||||
* ryanpudd
|
||||
* touilleWoman
|
||||
* ubaumann
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
32
doc/en/announce/release-8.0.0rc2.rst
Normal file
32
doc/en/announce/release-8.0.0rc2.rst
Normal file
@@ -0,0 +1,32 @@
|
||||
pytest-8.0.0rc2
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.0.0rc2 prerelease!
|
||||
|
||||
This is a prerelease, not intended for production use, but to test the upcoming features and improvements
|
||||
in order to catch any major problems before the final version is released to the major public.
|
||||
|
||||
We appreciate your help testing this out before the final release, making sure to report any
|
||||
regressions to our issue tracker:
|
||||
|
||||
https://github.com/pytest-dev/pytest/issues
|
||||
|
||||
When doing so, please include the string ``[prerelease]`` in the title.
|
||||
|
||||
You can upgrade from PyPI via:
|
||||
|
||||
pip install pytest==8.0.0rc2
|
||||
|
||||
Users are encouraged to take a look at the CHANGELOG carefully:
|
||||
|
||||
https://docs.pytest.org/en/release-8.0.0rc2/changelog.html
|
||||
|
||||
Thanks to all the contributors to this release:
|
||||
|
||||
* Ben Brown
|
||||
* Bruno Oliveira
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
21
doc/en/announce/release-8.0.1.rst
Normal file
21
doc/en/announce/release-8.0.1.rst
Normal file
@@ -0,0 +1,21 @@
|
||||
pytest-8.0.1
|
||||
=======================================
|
||||
|
||||
pytest 8.0.1 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Clément Robert
|
||||
* Pierre Sassoulas
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
18
doc/en/announce/release-8.0.2.rst
Normal file
18
doc/en/announce/release-8.0.2.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
pytest-8.0.2
|
||||
=======================================
|
||||
|
||||
pytest 8.0.2 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
54
doc/en/announce/release-8.1.0.rst
Normal file
54
doc/en/announce/release-8.1.0.rst
Normal file
@@ -0,0 +1,54 @@
|
||||
pytest-8.1.0
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.1.0 release!
|
||||
|
||||
This release contains new features, improvements, and bug fixes,
|
||||
the full list of changes is available in the changelog:
|
||||
|
||||
https://docs.pytest.org/en/stable/changelog.html
|
||||
|
||||
For complete documentation, please visit:
|
||||
|
||||
https://docs.pytest.org/en/stable/
|
||||
|
||||
As usual, you can upgrade from PyPI via:
|
||||
|
||||
pip install -U pytest
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Ben Brown
|
||||
* Ben Leith
|
||||
* Bruno Oliveira
|
||||
* Clément Robert
|
||||
* Dave Hall
|
||||
* Dương Quốc Khánh
|
||||
* Eero Vaher
|
||||
* Eric Larson
|
||||
* Fabian Sturm
|
||||
* Faisal Fawad
|
||||
* Florian Bruhin
|
||||
* Franck Charras
|
||||
* Joachim B Haga
|
||||
* John Litborn
|
||||
* Loïc Estève
|
||||
* Marc Bresson
|
||||
* Patrick Lannigan
|
||||
* Pierre Sassoulas
|
||||
* Ran Benita
|
||||
* Reagan Lee
|
||||
* Ronny Pfannschmidt
|
||||
* Russell Martin
|
||||
* clee2000
|
||||
* donghui
|
||||
* faph
|
||||
* jakkdl
|
||||
* mrbean-bremen
|
||||
* robotherapist
|
||||
* whysage
|
||||
* woutdenolf
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
18
doc/en/announce/release-8.1.1.rst
Normal file
18
doc/en/announce/release-8.1.1.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
pytest-8.1.1
|
||||
=======================================
|
||||
|
||||
pytest 8.1.1 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
18
doc/en/announce/release-8.1.2.rst
Normal file
18
doc/en/announce/release-8.1.2.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
pytest-8.1.2
|
||||
=======================================
|
||||
|
||||
pytest 8.1.2 has just been released to PyPI.
|
||||
|
||||
This is a bug-fix release, being a drop-in replacement. To upgrade::
|
||||
|
||||
pip install --upgrade pytest
|
||||
|
||||
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
43
doc/en/announce/release-8.2.0.rst
Normal file
43
doc/en/announce/release-8.2.0.rst
Normal file
@@ -0,0 +1,43 @@
|
||||
pytest-8.2.0
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.2.0 release!
|
||||
|
||||
This release contains new features, improvements, and bug fixes,
|
||||
the full list of changes is available in the changelog:
|
||||
|
||||
https://docs.pytest.org/en/stable/changelog.html
|
||||
|
||||
For complete documentation, please visit:
|
||||
|
||||
https://docs.pytest.org/en/stable/
|
||||
|
||||
As usual, you can upgrade from PyPI via:
|
||||
|
||||
pip install -U pytest
|
||||
|
||||
Thanks to all of the contributors to this release:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Daniel Miller
|
||||
* Florian Bruhin
|
||||
* HolyMagician03-UMich
|
||||
* John Litborn
|
||||
* Levon Saldamli
|
||||
* Linghao Zhang
|
||||
* Manuel López-Ibáñez
|
||||
* Pierre Sassoulas
|
||||
* Ran Benita
|
||||
* Ronny Pfannschmidt
|
||||
* Sebastian Meyer
|
||||
* Shekhar verma
|
||||
* Tamir Duberstein
|
||||
* Tobias Stoeckmann
|
||||
* dj
|
||||
* jakkdl
|
||||
* poulami-sau
|
||||
* tserg
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
@@ -22,7 +22,7 @@ b) transitional: the old and new API don't conflict
|
||||
|
||||
We will only start the removal of deprecated functionality in major releases (e.g. if we deprecate something in 3.0 we will start to remove it in 4.0), and keep it around for at least two minor releases (e.g. if we deprecate something in 3.9 and 4.0 is the next release, we start to remove it in 5.0, not in 4.0).
|
||||
|
||||
A deprecated feature scheduled to be removed in major version X will use the warning class `PytestRemovedInXWarning` (a subclass of :class:`~pytest.PytestDeprecationwarning`).
|
||||
A deprecated feature scheduled to be removed in major version X will use the warning class `PytestRemovedInXWarning` (a subclass of :class:`~pytest.PytestDeprecationWarning`).
|
||||
|
||||
When the deprecation expires (e.g. 4.0 is released), we won't remove the deprecated functionality immediately, but will use the standard warning filters to turn `PytestRemovedInXWarning` (e.g. `PytestRemovedIn4Warning`) into **errors** by default. This approach makes it explicit that removal is imminent, and still gives you time to turn the deprecated feature into a warning instead of an error so it can be dealt with in your own time. In the next minor release (e.g. 4.1), the feature will be effectively removed.
|
||||
|
||||
@@ -87,6 +87,7 @@ Released pytest versions support all Python versions that are actively maintaine
|
||||
============== ===================
|
||||
pytest version min. Python version
|
||||
============== ===================
|
||||
8.0+ 3.8+
|
||||
7.1+ 3.7+
|
||||
6.2 - 7.0 3.6+
|
||||
5.0 - 6.1 3.5+
|
||||
|
||||
@@ -18,11 +18,11 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
|
||||
$ pytest --fixtures -v
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collected 0 items
|
||||
cache -- .../_pytest/cacheprovider.py:528
|
||||
cache -- .../_pytest/cacheprovider.py:542
|
||||
Return a cache object that can persist state between testing sessions.
|
||||
|
||||
cache.get(key, default)
|
||||
@@ -33,7 +33,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
|
||||
Values can be any object handled by the json stdlib module.
|
||||
|
||||
capsysbinary -- .../_pytest/capture.py:1001
|
||||
capsysbinary -- .../_pytest/capture.py:1003
|
||||
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
||||
|
||||
The captured output is made available via ``capsysbinary.readouterr()``
|
||||
@@ -43,7 +43,6 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_output(capsysbinary):
|
||||
@@ -51,7 +50,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
captured = capsysbinary.readouterr()
|
||||
assert captured.out == b"hello\n"
|
||||
|
||||
capfd -- .../_pytest/capture.py:1029
|
||||
capfd -- .../_pytest/capture.py:1030
|
||||
Enable text capturing of writes to file descriptors ``1`` and ``2``.
|
||||
|
||||
The captured output is made available via ``capfd.readouterr()`` method
|
||||
@@ -61,7 +60,6 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_system_echo(capfd):
|
||||
@@ -79,7 +77,6 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_system_echo(capfdbinary):
|
||||
@@ -87,7 +84,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
captured = capfdbinary.readouterr()
|
||||
assert captured.out == b"hello\n"
|
||||
|
||||
capsys -- .../_pytest/capture.py:973
|
||||
capsys -- .../_pytest/capture.py:976
|
||||
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
||||
|
||||
The captured output is made available via ``capsys.readouterr()`` method
|
||||
@@ -97,7 +94,6 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_output(capsys):
|
||||
@@ -105,7 +101,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
captured = capsys.readouterr()
|
||||
assert captured.out == "hello\n"
|
||||
|
||||
doctest_namespace [session scope] -- .../_pytest/doctest.py:737
|
||||
doctest_namespace [session scope] -- .../_pytest/doctest.py:738
|
||||
Fixture that returns a :py:class:`dict` that will be injected into the
|
||||
namespace of doctests.
|
||||
|
||||
@@ -119,7 +115,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
|
||||
For more details: :ref:`doctest_namespace`.
|
||||
|
||||
pytestconfig [session scope] -- .../_pytest/fixtures.py:1353
|
||||
pytestconfig [session scope] -- .../_pytest/fixtures.py:1335
|
||||
Session-scoped fixture that returns the session's :class:`pytest.Config`
|
||||
object.
|
||||
|
||||
@@ -129,7 +125,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
if pytestconfig.getoption("verbose") > 0:
|
||||
...
|
||||
|
||||
record_property -- .../_pytest/junitxml.py:282
|
||||
record_property -- .../_pytest/junitxml.py:284
|
||||
Add extra properties to the calling test.
|
||||
|
||||
User properties become part of the test report and are available to the
|
||||
@@ -143,13 +139,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
def test_function(record_property):
|
||||
record_property("example_key", 1)
|
||||
|
||||
record_xml_attribute -- .../_pytest/junitxml.py:305
|
||||
record_xml_attribute -- .../_pytest/junitxml.py:307
|
||||
Add extra xml attributes to the tag for the calling test.
|
||||
|
||||
The fixture is callable with ``name, value``. The value is
|
||||
automatically XML-encoded.
|
||||
|
||||
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
|
||||
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:345
|
||||
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
|
||||
|
||||
This is suitable to writing global information regarding the entire test
|
||||
@@ -174,18 +170,18 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
`pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
|
||||
:issue:`7767` for details.
|
||||
|
||||
tmpdir_factory [session scope] -- .../_pytest/legacypath.py:302
|
||||
tmpdir_factory [session scope] -- .../_pytest/legacypath.py:303
|
||||
Return a :class:`pytest.TempdirFactory` instance for the test session.
|
||||
|
||||
tmpdir -- .../_pytest/legacypath.py:309
|
||||
tmpdir -- .../_pytest/legacypath.py:310
|
||||
Return a temporary directory path object which is unique to each test
|
||||
function invocation, created as a sub directory of the base temporary
|
||||
directory.
|
||||
|
||||
By default, a new base temporary directory is created each test session,
|
||||
and old bases are removed after 3 sessions, to aid in debugging. If
|
||||
``--basetemp`` is used then it is cleared each session. See :ref:`base
|
||||
temporary directory`.
|
||||
``--basetemp`` is used then it is cleared each session. See
|
||||
:ref:`temporary directory location and retention`.
|
||||
|
||||
The returned object is a `legacy_path`_ object.
|
||||
|
||||
@@ -196,7 +192,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
|
||||
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
|
||||
|
||||
caplog -- .../_pytest/logging.py:570
|
||||
caplog -- .../_pytest/logging.py:602
|
||||
Access and control log capturing.
|
||||
|
||||
Captured logs are available through the following properties/methods::
|
||||
@@ -207,7 +203,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
* caplog.record_tuples -> list of (logger_name, level, message) tuples
|
||||
* caplog.clear() -> clear captured records and formatted log output string
|
||||
|
||||
monkeypatch -- .../_pytest/monkeypatch.py:30
|
||||
monkeypatch -- .../_pytest/monkeypatch.py:33
|
||||
A convenient fixture for monkey-patching.
|
||||
|
||||
The fixture provides these methods to modify objects, dictionaries, or
|
||||
@@ -231,16 +227,16 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
To undo modifications done by the fixture in a contained scope,
|
||||
use :meth:`context() <pytest.MonkeyPatch.context>`.
|
||||
|
||||
recwarn -- .../_pytest/recwarn.py:30
|
||||
recwarn -- .../_pytest/recwarn.py:32
|
||||
Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
|
||||
|
||||
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
|
||||
on warning categories.
|
||||
|
||||
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:245
|
||||
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:242
|
||||
Return a :class:`pytest.TempPathFactory` instance for the test session.
|
||||
|
||||
tmp_path -- .../_pytest/tmpdir.py:260
|
||||
tmp_path -- .../_pytest/tmpdir.py:257
|
||||
Return a temporary directory path object which is unique to each test
|
||||
function invocation, created as a sub directory of the base temporary
|
||||
directory.
|
||||
@@ -249,8 +245,8 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||
and old bases are removed after 3 sessions, to aid in debugging.
|
||||
This behavior can be configured with :confval:`tmp_path_retention_count` and
|
||||
:confval:`tmp_path_retention_policy`.
|
||||
If ``--basetemp`` is used then it is cleared each session. See :ref:`base
|
||||
temporary directory`.
|
||||
If ``--basetemp`` is used then it is cleared each session. See
|
||||
:ref:`temporary directory location and retention`.
|
||||
|
||||
The returned object is a :class:`pathlib.Path` object.
|
||||
|
||||
|
||||
@@ -28,6 +28,758 @@ with advance notice in the **Deprecations** section of releases.
|
||||
|
||||
.. towncrier release notes start
|
||||
|
||||
pytest 8.2.0 (2024-04-27)
|
||||
=========================
|
||||
|
||||
Deprecations
|
||||
------------
|
||||
|
||||
- `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: A deprecation warning is now raised when implementations of one of the following hooks request a deprecated ``py.path.local`` parameter instead of the ``pathlib.Path`` parameter which replaced it:
|
||||
|
||||
- :hook:`pytest_ignore_collect` - the ``path`` parameter - use ``collection_path`` instead.
|
||||
- :hook:`pytest_collect_file` - the ``path`` parameter - use ``file_path`` instead.
|
||||
- :hook:`pytest_pycollect_makemodule` - the ``path`` parameter - use ``module_path`` instead.
|
||||
- :hook:`pytest_report_header` - the ``startdir`` parameter - use ``start_path`` instead.
|
||||
- :hook:`pytest_report_collectionfinish` - the ``startdir`` parameter - use ``start_path`` instead.
|
||||
|
||||
The replacement parameters are available since pytest 7.0.0.
|
||||
The old parameters will be removed in pytest 9.0.0.
|
||||
|
||||
See :ref:`legacy-path-hooks-deprecated` for more details.
|
||||
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- `#11871 <https://github.com/pytest-dev/pytest/issues/11871>`_: Added support for reading command line arguments from a file using the prefix character ``@``, like e.g.: ``pytest @tests.txt``. The file must have one argument per line.
|
||||
|
||||
See :ref:`Read arguments from file <args-from-file>` for details.
|
||||
|
||||
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#11523 <https://github.com/pytest-dev/pytest/issues/11523>`_: :func:`pytest.importorskip` will now issue a warning if the module could be found, but raised :class:`ImportError` instead of :class:`ModuleNotFoundError`.
|
||||
|
||||
The warning can be suppressed by passing ``exc_type=ImportError`` to :func:`pytest.importorskip`.
|
||||
|
||||
See :ref:`import-or-skip-import-error` for details.
|
||||
|
||||
|
||||
- `#11728 <https://github.com/pytest-dev/pytest/issues/11728>`_: For ``unittest``-based tests, exceptions during class cleanup (as raised by functions registered with :meth:`TestCase.addClassCleanup <unittest.TestCase.addClassCleanup>`) are now reported instead of silently failing.
|
||||
|
||||
|
||||
- `#11777 <https://github.com/pytest-dev/pytest/issues/11777>`_: Text is no longer truncated in the ``short test summary info`` section when ``-vv`` is given.
|
||||
|
||||
|
||||
- `#12112 <https://github.com/pytest-dev/pytest/issues/12112>`_: Improved namespace packages detection when :confval:`consider_namespace_packages` is enabled, covering more situations (like editable installs).
|
||||
|
||||
|
||||
- `#9502 <https://github.com/pytest-dev/pytest/issues/9502>`_: Added :envvar:`PYTEST_VERSION` environment variable which is defined at the start of the pytest session and undefined afterwards. It contains the value of ``pytest.__version__``, and among other things can be used to easily check if code is running from within a pytest run.
|
||||
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#12065 <https://github.com/pytest-dev/pytest/issues/12065>`_: Fixed a regression in pytest 8.0.0 where test classes containing ``setup_method`` and tests using ``@staticmethod`` or ``@classmethod`` would crash with ``AttributeError: 'NoneType' object has no attribute 'setup_method'``.
|
||||
|
||||
Now the :attr:`request.instance <pytest.FixtureRequest.instance>` attribute of tests using ``@staticmethod`` and ``@classmethod`` is no longer ``None``, but a fresh instance of the class, like in non-static methods.
|
||||
Previously it was ``None``, and all fixtures of such tests would share a single ``self``.
|
||||
|
||||
|
||||
- `#12135 <https://github.com/pytest-dev/pytest/issues/12135>`_: Fixed issue where fixtures adding their finalizer multiple times to fixtures they request would cause unreliable and non-intuitive teardown ordering in some instances.
|
||||
|
||||
|
||||
- `#12194 <https://github.com/pytest-dev/pytest/issues/12194>`_: Fixed a bug with ``--importmode=importlib`` and ``--doctest-modules`` where child modules did not appear as attributes in parent modules.
|
||||
|
||||
|
||||
- `#1489 <https://github.com/pytest-dev/pytest/issues/1489>`_: Fixed some instances where teardown of higher-scoped fixtures was not happening in the reverse order they were initialized in.
|
||||
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: ``pluggy>=1.5.0`` is now required.
|
||||
|
||||
|
||||
- `#12167 <https://github.com/pytest-dev/pytest/issues/12167>`_: :ref:`cache <cache>`: create supporting files (``CACHEDIR.TAG``, ``.gitignore``, etc.) in a temporary directory to provide atomic semantics.
|
||||
|
||||
|
||||
pytest 8.1.2 (2024-04-26)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#12114 <https://github.com/pytest-dev/pytest/issues/12114>`_: Fixed error in :func:`pytest.approx` when used with `numpy` arrays and comparing with other types.
|
||||
|
||||
|
||||
pytest 8.1.1 (2024-03-08)
|
||||
=========================
|
||||
|
||||
.. note::
|
||||
|
||||
This release is not a usual bug fix release -- it contains features and improvements, being a follow up
|
||||
to ``8.1.0``, which has been yanked from PyPI.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Added the new :confval:`consider_namespace_packages` configuration option, defaulting to ``False``.
|
||||
|
||||
If set to ``True``, pytest will attempt to identify modules that are part of `namespace packages <https://packaging.python.org/en/latest/guides/packaging-namespace-packages>`__ when importing modules.
|
||||
|
||||
|
||||
- `#11653 <https://github.com/pytest-dev/pytest/issues/11653>`_: Added the new :confval:`verbosity_test_cases` configuration option for fine-grained control of test execution verbosity.
|
||||
See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details.
|
||||
|
||||
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#10865 <https://github.com/pytest-dev/pytest/issues/10865>`_: :func:`pytest.warns` now validates that :func:`warnings.warn` was called with a `str` or a `Warning`.
|
||||
Currently in Python it is possible to use other types, however this causes an exception when :func:`warnings.filterwarnings` is used to filter those warnings (see `CPython #103577 <https://github.com/python/cpython/issues/103577>`__ for a discussion).
|
||||
While this can be considered a bug in CPython, we decided to put guards in pytest as the error message produced without this check in place is confusing.
|
||||
|
||||
|
||||
- `#11311 <https://github.com/pytest-dev/pytest/issues/11311>`_: When using ``--override-ini`` for paths in invocations without a configuration file defined, the current working directory is used
|
||||
as the relative directory.
|
||||
|
||||
Previoulsy this would raise an :class:`AssertionError`.
|
||||
|
||||
|
||||
- `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: :ref:`--import-mode=importlib <import-mode-importlib>` now tries to import modules using the standard import mechanism (but still without changing :py:data:`sys.path`), falling back to importing modules directly only if that fails.
|
||||
|
||||
This means that installed packages will be imported under their canonical name if possible first, for example ``app.core.models``, instead of having the module name always be derived from their path (for example ``.env310.lib.site_packages.app.core.models``).
|
||||
|
||||
|
||||
- `#11801 <https://github.com/pytest-dev/pytest/issues/11801>`_: Added the :func:`iter_parents() <_pytest.nodes.Node.iter_parents>` helper method on nodes.
|
||||
It is similar to :func:`listchain <_pytest.nodes.Node.listchain>`, but goes from bottom to top, and returns an iterator, not a list.
|
||||
|
||||
|
||||
- `#11850 <https://github.com/pytest-dev/pytest/issues/11850>`_: Added support for :data:`sys.last_exc` for post-mortem debugging on Python>=3.12.
|
||||
|
||||
|
||||
- `#11962 <https://github.com/pytest-dev/pytest/issues/11962>`_: In case no other suitable candidates for configuration file are found, a ``pyproject.toml`` (even without a ``[tool.pytest.ini_options]`` table) will be considered as the configuration file and define the ``rootdir``.
|
||||
|
||||
|
||||
- `#11978 <https://github.com/pytest-dev/pytest/issues/11978>`_: Add ``--log-file-mode`` option to the logging plugin, enabling appending to log-files. This option accepts either ``"w"`` or ``"a"`` and defaults to ``"w"``.
|
||||
|
||||
Previously, the mode was hard-coded to be ``"w"`` which truncates the file before logging.
|
||||
|
||||
|
||||
- `#12047 <https://github.com/pytest-dev/pytest/issues/12047>`_: When multiple finalizers of a fixture raise an exception, now all exceptions are reported as an exception group.
|
||||
Previously, only the first exception was reported.
|
||||
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Fixed regression where ``--importmode=importlib`` would import non-test modules more than once.
|
||||
|
||||
|
||||
- `#11904 <https://github.com/pytest-dev/pytest/issues/11904>`_: Fixed a regression in pytest 8.0.0 that would cause test collection to fail due to permission errors when using ``--pyargs``.
|
||||
|
||||
This change improves the collection tree for tests specified using ``--pyargs``, see :pull:`12043` for a comparison with pytest 8.0 and <8.
|
||||
|
||||
|
||||
- `#12011 <https://github.com/pytest-dev/pytest/issues/12011>`_: Fixed a regression in 8.0.1 whereby ``setup_module`` xunit-style fixtures are not executed when ``--doctest-modules`` is passed.
|
||||
|
||||
|
||||
- `#12014 <https://github.com/pytest-dev/pytest/issues/12014>`_: Fix the ``stacklevel`` used when warning about marks used on fixtures.
|
||||
|
||||
|
||||
- `#12039 <https://github.com/pytest-dev/pytest/issues/12039>`_: Fixed a regression in ``8.0.2`` where tests created using :fixture:`tmp_path` have been collected multiple times in CI under Windows.
|
||||
|
||||
|
||||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- `#11790 <https://github.com/pytest-dev/pytest/issues/11790>`_: Documented the retention of temporary directories created using the ``tmp_path`` fixture in more detail.
|
||||
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- `#11785 <https://github.com/pytest-dev/pytest/issues/11785>`_: Some changes were made to private functions which may affect plugins which access them:
|
||||
|
||||
- ``FixtureManager._getautousenames()`` now takes a ``Node`` itself instead of the nodeid.
|
||||
- ``FixtureManager.getfixturedefs()`` now takes the ``Node`` itself instead of the nodeid.
|
||||
- The ``_pytest.nodes.iterparentnodeids()`` function is removed without replacement.
|
||||
Prefer to traverse the node hierarchy itself instead.
|
||||
If you really need to, copy the function from the previous pytest release.
|
||||
|
||||
|
||||
- `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: Delayed the deprecation of the following features to ``9.0.0``:
|
||||
|
||||
* :ref:`node-ctor-fspath-deprecation`.
|
||||
* :ref:`legacy-path-hooks-deprecated`.
|
||||
|
||||
It was discovered after ``8.1.0`` was released that the warnings about the impeding removal were not being displayed, so the team decided to revert the removal.
|
||||
|
||||
This is the reason for ``8.1.0`` being yanked.
|
||||
|
||||
|
||||
pytest 8.1.0 (YANKED)
|
||||
=====================
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
This release has been **yanked**: it broke some plugins without the proper warning period, due to
|
||||
some warnings not showing up as expected.
|
||||
|
||||
See `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`__.
|
||||
|
||||
|
||||
pytest 8.0.2 (2024-02-24)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11895 <https://github.com/pytest-dev/pytest/issues/11895>`_: Fix collection on Windows where initial paths contain the short version of a path (for example ``c:\PROGRA~1\tests``).
|
||||
|
||||
|
||||
- `#11953 <https://github.com/pytest-dev/pytest/issues/11953>`_: Fix an ``IndexError`` crash raising from ``getstatementrange_ast``.
|
||||
|
||||
|
||||
- `#12021 <https://github.com/pytest-dev/pytest/issues/12021>`_: Reverted a fix to `--maxfail` handling in pytest 8.0.0 because it caused a regression in pytest-xdist whereby session fixture teardowns may get executed multiple times when the max-fails is reached.
|
||||
|
||||
|
||||
pytest 8.0.1 (2024-02-16)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11875 <https://github.com/pytest-dev/pytest/issues/11875>`_: Correctly handle errors from :func:`getpass.getuser` in Python 3.13.
|
||||
|
||||
|
||||
- `#11879 <https://github.com/pytest-dev/pytest/issues/11879>`_: Fix an edge case where ``ExceptionInfo._stringify_exception`` could crash :func:`pytest.raises`.
|
||||
|
||||
|
||||
- `#11906 <https://github.com/pytest-dev/pytest/issues/11906>`_: Fix regression with :func:`pytest.warns` using custom warning subclasses which have more than one parameter in their `__init__`.
|
||||
|
||||
|
||||
- `#11907 <https://github.com/pytest-dev/pytest/issues/11907>`_: Fix a regression in pytest 8.0.0 whereby calling :func:`pytest.skip` and similar control-flow exceptions within a :func:`pytest.warns()` block would get suppressed instead of propagating.
|
||||
|
||||
|
||||
- `#11929 <https://github.com/pytest-dev/pytest/issues/11929>`_: Fix a regression in pytest 8.0.0 whereby autouse fixtures defined in a module get ignored by the doctests in the module.
|
||||
|
||||
|
||||
- `#11937 <https://github.com/pytest-dev/pytest/issues/11937>`_: Fix a regression in pytest 8.0.0 whereby items would be collected in reverse order in some circumstances.
|
||||
|
||||
|
||||
pytest 8.0.0 (2024-01-27)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11842 <https://github.com/pytest-dev/pytest/issues/11842>`_: Properly escape the ``reason`` of a :ref:`skip <pytest.mark.skip ref>` mark when writing JUnit XML files.
|
||||
|
||||
|
||||
- `#11861 <https://github.com/pytest-dev/pytest/issues/11861>`_: Avoid microsecond exceeds ``1_000_000`` when using ``log-date-format`` with ``%f`` specifier, which might cause the test suite to crash.
|
||||
|
||||
|
||||
pytest 8.0.0rc2 (2024-01-17)
|
||||
============================
|
||||
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#11233 <https://github.com/pytest-dev/pytest/issues/11233>`_: Improvements to ``-r`` for xfailures and xpasses:
|
||||
|
||||
* Report tracebacks for xfailures when ``-rx`` is set.
|
||||
* Report captured output for xpasses when ``-rX`` is set.
|
||||
* For xpasses, add ``-`` in summary between test name and reason, to match how xfail is displayed.
|
||||
|
||||
- `#11825 <https://github.com/pytest-dev/pytest/issues/11825>`_: The :hook:`pytest_plugin_registered` hook has a new ``plugin_name`` parameter containing the name by which ``plugin`` is registered.
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11706 <https://github.com/pytest-dev/pytest/issues/11706>`_: Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`.
|
||||
|
||||
NOTE: This change was reverted in pytest 8.0.2 to fix a `regression <https://github.com/pytest-dev/pytest-xdist/issues/1024>`_ it caused in pytest-xdist.
|
||||
|
||||
|
||||
- `#11758 <https://github.com/pytest-dev/pytest/issues/11758>`_: Fixed ``IndexError: string index out of range`` crash in ``if highlighted[-1] == "\n" and source[-1] != "\n"``.
|
||||
This bug was introduced in pytest 8.0.0rc1.
|
||||
|
||||
|
||||
- `#9765 <https://github.com/pytest-dev/pytest/issues/9765>`_, `#11816 <https://github.com/pytest-dev/pytest/issues/11816>`_: Fixed a frustrating bug that afflicted some users with the only error being ``assert mod not in mods``. The issue was caused by the fact that ``str(Path(mod))`` and ``mod.__file__`` don't necessarily produce the same string, and was being erroneously used interchangably in some places in the code.
|
||||
|
||||
This fix also broke the internal API of ``PytestPluginManager.consider_conftest`` by introducing a new parameter -- we mention this in case it is being used by external code, even if marked as *private*.
|
||||
|
||||
|
||||
pytest 8.0.0rc1 (2023-12-30)
|
||||
============================
|
||||
|
||||
Breaking Changes
|
||||
----------------
|
||||
|
||||
Old Deprecations Are Now Errors
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- `#7363 <https://github.com/pytest-dev/pytest/issues/7363>`_: **PytestRemovedIn8Warning deprecation warnings are now errors by default.**
|
||||
|
||||
Following our plan to remove deprecated features with as little disruption as
|
||||
possible, all warnings of type ``PytestRemovedIn8Warning`` now generate errors
|
||||
instead of warning messages by default.
|
||||
|
||||
**The affected features will be effectively removed in pytest 8.1**, so please consult the
|
||||
:ref:`deprecations` section in the docs for directions on how to update existing code.
|
||||
|
||||
In the pytest ``8.0.X`` series, it is possible to change the errors back into warnings as a
|
||||
stopgap measure by adding this to your ``pytest.ini`` file:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[pytest]
|
||||
filterwarnings =
|
||||
ignore::pytest.PytestRemovedIn8Warning
|
||||
|
||||
But this will stop working when pytest ``8.1`` is released.
|
||||
|
||||
**If you have concerns** about the removal of a specific feature, please add a
|
||||
comment to :issue:`7363`.
|
||||
|
||||
|
||||
Version Compatibility
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- `#11151 <https://github.com/pytest-dev/pytest/issues/11151>`_: Dropped support for Python 3.7, which `reached end-of-life on 2023-06-27 <https://devguide.python.org/versions/>`__.
|
||||
|
||||
|
||||
- ``pluggy>=1.3.0`` is now required.
|
||||
|
||||
|
||||
Collection Changes
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In this version we've made several breaking changes to pytest's collection phase,
|
||||
particularly around how filesystem directories and Python packages are collected,
|
||||
fixing deficiencies and allowing for cleanups and improvements to pytest's internals.
|
||||
A deprecation period for these changes was not possible.
|
||||
|
||||
|
||||
- `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Files and directories are now collected in alphabetical order jointly, unless changed by a plugin.
|
||||
Previously, files were collected before directories.
|
||||
See below for an example.
|
||||
|
||||
|
||||
- `#8976 <https://github.com/pytest-dev/pytest/issues/8976>`_: Running `pytest pkg/__init__.py` now collects the `pkg/__init__.py` file (module) only.
|
||||
Previously, it collected the entire `pkg` package, including other test files in the directory, but excluding tests in the `__init__.py` file itself
|
||||
(unless :confval:`python_files` was changed to allow `__init__.py` file).
|
||||
|
||||
To collect the entire package, specify just the directory: `pytest pkg`.
|
||||
|
||||
|
||||
- `#11137 <https://github.com/pytest-dev/pytest/issues/11137>`_: :class:`pytest.Package` is no longer a :class:`pytest.Module` or :class:`pytest.File`.
|
||||
|
||||
The ``Package`` collector node designates a Python package, that is, a directory with an `__init__.py` file.
|
||||
Previously ``Package`` was a subtype of ``pytest.Module`` (which represents a single Python module),
|
||||
the module being the `__init__.py` file.
|
||||
This has been deemed a design mistake (see :issue:`11137` and :issue:`7777` for details).
|
||||
|
||||
The ``path`` property of ``Package`` nodes now points to the package directory instead of the ``__init__.py`` file.
|
||||
|
||||
Note that a ``Module`` node for ``__init__.py`` (which is not a ``Package``) may still exist,
|
||||
if it is picked up during collection (e.g. if you configured :confval:`python_files` to include ``__init__.py`` files).
|
||||
|
||||
|
||||
- `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Added a new :class:`pytest.Directory` base collection node, which all collector nodes for filesystem directories are expected to subclass.
|
||||
This is analogous to the existing :class:`pytest.File` for file nodes.
|
||||
|
||||
Changed :class:`pytest.Package` to be a subclass of :class:`pytest.Directory`.
|
||||
A ``Package`` represents a filesystem directory which is a Python package,
|
||||
i.e. contains an ``__init__.py`` file.
|
||||
|
||||
:class:`pytest.Package` now only collects files in its own directory; previously it collected recursively.
|
||||
Sub-directories are collected as their own collector nodes, which then collect themselves, thus creating a collection tree which mirrors the filesystem hierarchy.
|
||||
|
||||
Added a new :class:`pytest.Dir` concrete collection node, a subclass of :class:`pytest.Directory`.
|
||||
This node represents a filesystem directory, which is not a :class:`pytest.Package`,
|
||||
that is, does not contain an ``__init__.py`` file.
|
||||
Similarly to ``Package``, it only collects the files in its own directory.
|
||||
|
||||
:class:`pytest.Session` now only collects the initial arguments, without recursing into directories.
|
||||
This work is now done by the :func:`recursive expansion process <pytest.Collector.collect>` of directory collector nodes.
|
||||
|
||||
:attr:`session.name <pytest.Session.name>` is now ``""``; previously it was the rootdir directory name.
|
||||
This matches :attr:`session.nodeid <_pytest.nodes.Node.nodeid>` which has always been `""`.
|
||||
|
||||
The collection tree now contains directories/packages up to the :ref:`rootdir <rootdir>`,
|
||||
for initial arguments that are found within the rootdir.
|
||||
For files outside the rootdir, only the immediate directory/package is collected --
|
||||
note however that collecting from outside the rootdir is discouraged.
|
||||
|
||||
As an example, given the following filesystem tree::
|
||||
|
||||
myroot/
|
||||
pytest.ini
|
||||
top/
|
||||
├── aaa
|
||||
│ └── test_aaa.py
|
||||
├── test_a.py
|
||||
├── test_b
|
||||
│ ├── __init__.py
|
||||
│ └── test_b.py
|
||||
├── test_c.py
|
||||
└── zzz
|
||||
├── __init__.py
|
||||
└── test_zzz.py
|
||||
|
||||
the collection tree, as shown by `pytest --collect-only top/` but with the otherwise-hidden :class:`~pytest.Session` node added for clarity,
|
||||
is now the following::
|
||||
|
||||
<Session>
|
||||
<Dir myroot>
|
||||
<Dir top>
|
||||
<Dir aaa>
|
||||
<Module test_aaa.py>
|
||||
<Function test_it>
|
||||
<Module test_a.py>
|
||||
<Function test_it>
|
||||
<Package test_b>
|
||||
<Module test_b.py>
|
||||
<Function test_it>
|
||||
<Module test_c.py>
|
||||
<Function test_it>
|
||||
<Package zzz>
|
||||
<Module test_zzz.py>
|
||||
<Function test_it>
|
||||
|
||||
Previously, it was::
|
||||
|
||||
<Session>
|
||||
<Module top/test_a.py>
|
||||
<Function test_it>
|
||||
<Module top/test_c.py>
|
||||
<Function test_it>
|
||||
<Module top/aaa/test_aaa.py>
|
||||
<Function test_it>
|
||||
<Package test_b>
|
||||
<Module test_b.py>
|
||||
<Function test_it>
|
||||
<Package zzz>
|
||||
<Module test_zzz.py>
|
||||
<Function test_it>
|
||||
|
||||
Code/plugins which rely on a specific shape of the collection tree might need to update.
|
||||
|
||||
|
||||
- `#11676 <https://github.com/pytest-dev/pytest/issues/11676>`_: The classes :class:`~_pytest.nodes.Node`, :class:`~pytest.Collector`, :class:`~pytest.Item`, :class:`~pytest.File`, :class:`~_pytest.nodes.FSCollector` are now marked abstract (see :mod:`abc`).
|
||||
|
||||
We do not expect this change to affect users and plugin authors, it will only cause errors when the code is already wrong or problematic.
|
||||
|
||||
|
||||
Other breaking changes
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These are breaking changes where deprecation was not possible.
|
||||
|
||||
|
||||
- `#11282 <https://github.com/pytest-dev/pytest/issues/11282>`_: Sanitized the handling of the ``default`` parameter when defining configuration options.
|
||||
|
||||
Previously if ``default`` was not supplied for :meth:`parser.addini <pytest.Parser.addini>` and the configuration option value was not defined in a test session, then calls to :func:`config.getini <pytest.Config.getini>` returned an *empty list* or an *empty string* depending on whether ``type`` was supplied or not respectively, which is clearly incorrect. Also, ``None`` was not honored even if ``default=None`` was used explicitly while defining the option.
|
||||
|
||||
Now the behavior of :meth:`parser.addini <pytest.Parser.addini>` is as follows:
|
||||
|
||||
* If ``default`` is NOT passed but ``type`` is provided, then a type-specific default will be returned. For example ``type=bool`` will return ``False``, ``type=str`` will return ``""``, etc.
|
||||
* If ``default=None`` is passed and the option is not defined in a test session, then ``None`` will be returned, regardless of the ``type``.
|
||||
* If neither ``default`` nor ``type`` are provided, assume ``type=str`` and return ``""`` as default (this is as per previous behavior).
|
||||
|
||||
The team decided to not introduce a deprecation period for this change, as doing so would be complicated both in terms of communicating this to the community as well as implementing it, and also because the team believes this change should not break existing plugins except in rare cases.
|
||||
|
||||
|
||||
- `#11667 <https://github.com/pytest-dev/pytest/issues/11667>`_: pytest's ``setup.py`` file is removed.
|
||||
If you relied on this file, e.g. to install pytest using ``setup.py install``,
|
||||
please see `Why you shouldn't invoke setup.py directly <https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary>`_ for alternatives.
|
||||
|
||||
|
||||
- `#9288 <https://github.com/pytest-dev/pytest/issues/9288>`_: :func:`~pytest.warns` now re-emits unmatched warnings when the context
|
||||
closes -- previously it would consume all warnings, hiding those that were not
|
||||
matched by the function.
|
||||
|
||||
While this is a new feature, we announce it as a breaking change
|
||||
because many test suites are configured to error-out on warnings, and will
|
||||
therefore fail on the newly-re-emitted warnings.
|
||||
|
||||
|
||||
- The internal ``FixtureManager.getfixtureclosure`` method has changed. Plugins which use this method or
|
||||
which subclass ``FixtureManager`` and overwrite that method will need to adapt to the change.
|
||||
|
||||
|
||||
|
||||
Deprecations
|
||||
------------
|
||||
|
||||
- `#10465 <https://github.com/pytest-dev/pytest/issues/10465>`_: Test functions returning a value other than ``None`` will now issue a :class:`pytest.PytestWarning` instead of ``pytest.PytestRemovedIn8Warning``, meaning this will stay a warning instead of becoming an error in the future.
|
||||
|
||||
|
||||
- `#3664 <https://github.com/pytest-dev/pytest/issues/3664>`_: Applying a mark to a fixture function now issues a warning: marks in fixtures never had any effect, but it is a common user error to apply a mark to a fixture (for example ``usefixtures``) and expect it to work.
|
||||
|
||||
This will become an error in pytest 9.0.
|
||||
|
||||
|
||||
|
||||
Features and Improvements
|
||||
-------------------------
|
||||
|
||||
Improved Diffs
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
These changes improve the diffs that pytest prints when an assertion fails.
|
||||
Note that syntax highlighting requires the ``pygments`` package.
|
||||
|
||||
|
||||
- `#11520 <https://github.com/pytest-dev/pytest/issues/11520>`_: The very verbose (``-vv``) diff output is now colored as a diff instead of a big chunk of red.
|
||||
|
||||
Python code in error reports is now syntax-highlighted as Python.
|
||||
|
||||
The sections in the error reports are now better separated.
|
||||
|
||||
|
||||
- `#1531 <https://github.com/pytest-dev/pytest/issues/1531>`_: The very verbose diff (``-vv``) for every standard library container type is improved. The indentation is now consistent and the markers are on their own separate lines, which should reduce the diffs shown to users.
|
||||
|
||||
Previously, the standard Python pretty printer was used to generate the output, which puts opening and closing
|
||||
markers on the same line as the first/last entry, in addition to not having consistent indentation.
|
||||
|
||||
|
||||
- `#10617 <https://github.com/pytest-dev/pytest/issues/10617>`_: Added more comprehensive set assertion rewrites for comparisons other than equality ``==``, with
|
||||
the following operations now providing better failure messages: ``!=``, ``<=``, ``>=``, ``<``, and ``>``.
|
||||
|
||||
|
||||
Separate Control For Assertion Verbosity
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- `#11387 <https://github.com/pytest-dev/pytest/issues/11387>`_: Added the new :confval:`verbosity_assertions` configuration option for fine-grained control of failed assertions verbosity.
|
||||
|
||||
If you've ever wished that pytest always show you full diffs, but without making everything else verbose, this is for you.
|
||||
|
||||
See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details.
|
||||
|
||||
For plugin authors, :attr:`config.get_verbosity <pytest.Config.get_verbosity>` can be used to retrieve the verbosity level for a specific verbosity type.
|
||||
|
||||
|
||||
Additional Support For Exception Groups and ``__notes__``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These changes improve pytest's support for exception groups.
|
||||
|
||||
|
||||
- `#10441 <https://github.com/pytest-dev/pytest/issues/10441>`_: Added :func:`ExceptionInfo.group_contains() <pytest.ExceptionInfo.group_contains>`, an assertion helper that tests if an :class:`ExceptionGroup` contains a matching exception.
|
||||
|
||||
See :ref:`assert-matching-exception-groups` for an example.
|
||||
|
||||
|
||||
- `#11227 <https://github.com/pytest-dev/pytest/issues/11227>`_: Allow :func:`pytest.raises` ``match`` argument to match against `PEP-678 <https://peps.python.org/pep-0678/>` ``__notes__``.
|
||||
|
||||
|
||||
Custom Directory collectors
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- `#7777 <https://github.com/pytest-dev/pytest/issues/7777>`_: Added a new hook :hook:`pytest_collect_directory`,
|
||||
which is called by filesystem-traversing collector nodes,
|
||||
such as :class:`pytest.Session`, :class:`pytest.Dir` and :class:`pytest.Package`,
|
||||
to create a collector node for a sub-directory.
|
||||
It is expected to return a subclass of :class:`pytest.Directory`.
|
||||
This hook allows plugins to :ref:`customize the collection of directories <custom directory collectors>`.
|
||||
|
||||
|
||||
"New-style" Hook Wrappers
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- `#11122 <https://github.com/pytest-dev/pytest/issues/11122>`_: pytest now uses "new-style" hook wrappers internally, available since pluggy 1.2.0.
|
||||
See `pluggy's 1.2.0 changelog <https://pluggy.readthedocs.io/en/latest/changelog.html#pluggy-1-2-0-2023-06-21>`_ and the :ref:`updated docs <hookwrapper>` for details.
|
||||
|
||||
Plugins which want to use new-style wrappers can do so if they require ``pytest>=8``.
|
||||
|
||||
|
||||
Other Improvements
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- `#11216 <https://github.com/pytest-dev/pytest/issues/11216>`_: If a test is skipped from inside an :ref:`xunit setup fixture <classic xunit>`, the test summary now shows the test location instead of the fixture location.
|
||||
|
||||
|
||||
- `#11314 <https://github.com/pytest-dev/pytest/issues/11314>`_: Logging to a file using the ``--log-file`` option will use ``--log-level``, ``--log-format`` and ``--log-date-format`` as fallback
|
||||
if ``--log-file-level``, ``--log-file-format`` and ``--log-file-date-format`` are not provided respectively.
|
||||
|
||||
|
||||
- `#11610 <https://github.com/pytest-dev/pytest/issues/11610>`_: Added the :func:`LogCaptureFixture.filtering() <pytest.LogCaptureFixture.filtering>` context manager which
|
||||
adds a given :class:`logging.Filter` object to the :fixture:`caplog` fixture.
|
||||
|
||||
|
||||
- `#11447 <https://github.com/pytest-dev/pytest/issues/11447>`_: :func:`pytest.deprecated_call` now also considers warnings of type :class:`FutureWarning`.
|
||||
|
||||
|
||||
- `#11600 <https://github.com/pytest-dev/pytest/issues/11600>`_: Improved the documentation and type signature for :func:`pytest.mark.xfail <pytest.mark.xfail>`'s ``condition`` param to use ``False`` as the default value.
|
||||
|
||||
|
||||
- `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: :class:`~pytest.FixtureDef` is now exported as ``pytest.FixtureDef`` for typing purposes.
|
||||
|
||||
|
||||
- `#11353 <https://github.com/pytest-dev/pytest/issues/11353>`_: Added typing to :class:`~pytest.PytestPluginManager`.
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#10701 <https://github.com/pytest-dev/pytest/issues/10701>`_: :meth:`pytest.WarningsRecorder.pop` will return the most-closely-matched warning in the list,
|
||||
rather than the first warning which is an instance of the requested type.
|
||||
|
||||
|
||||
- `#11255 <https://github.com/pytest-dev/pytest/issues/11255>`_: Fixed crash on `parametrize(..., scope="package")` without a package present.
|
||||
|
||||
|
||||
- `#11277 <https://github.com/pytest-dev/pytest/issues/11277>`_: Fixed a bug that when there are multiple fixtures for an indirect parameter,
|
||||
the scope of the highest-scope fixture is picked for the parameter set, instead of that of the one with the narrowest scope.
|
||||
|
||||
|
||||
- `#11456 <https://github.com/pytest-dev/pytest/issues/11456>`_: Parametrized tests now *really do* ensure that the ids given to each input are unique - for
|
||||
example, ``a, a, a0`` now results in ``a1, a2, a0`` instead of the previous (buggy) ``a0, a1, a0``.
|
||||
This necessarily means changing nodeids where these were previously colliding, and for
|
||||
readability adds an underscore when non-unique ids end in a number.
|
||||
|
||||
|
||||
- `#11563 <https://github.com/pytest-dev/pytest/issues/11563>`_: Fixed a crash when using an empty string for the same parametrized value more than once.
|
||||
|
||||
|
||||
- `#11712 <https://github.com/pytest-dev/pytest/issues/11712>`_: Fixed handling ``NO_COLOR`` and ``FORCE_COLOR`` to ignore an empty value.
|
||||
|
||||
|
||||
- `#9036 <https://github.com/pytest-dev/pytest/issues/9036>`_: ``pytest.warns`` and similar functions now capture warnings when an exception is raised inside a ``with`` block.
|
||||
|
||||
|
||||
|
||||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- `#11011 <https://github.com/pytest-dev/pytest/issues/11011>`_: Added a warning about modifying the root logger during tests when using ``caplog``.
|
||||
|
||||
|
||||
- `#11065 <https://github.com/pytest-dev/pytest/issues/11065>`_: Use ``pytestconfig`` instead of ``request.config`` in cache example to be consistent with the API documentation.
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- `#11208 <https://github.com/pytest-dev/pytest/issues/11208>`_: The (internal) ``FixtureDef.cached_result`` type has changed.
|
||||
Now the third item ``cached_result[2]``, when set, is an exception instance instead of an exception triplet.
|
||||
|
||||
|
||||
- `#11218 <https://github.com/pytest-dev/pytest/issues/11218>`_: (This entry is meant to assist plugins which access private pytest internals to instantiate ``FixtureRequest`` objects.)
|
||||
|
||||
:class:`~pytest.FixtureRequest` is now an abstract class which can't be instantiated directly.
|
||||
A new concrete ``TopRequest`` subclass of ``FixtureRequest`` has been added for the ``request`` fixture in test functions,
|
||||
as counterpart to the existing ``SubRequest`` subclass for the ``request`` fixture in fixture functions.
|
||||
|
||||
|
||||
- `#11315 <https://github.com/pytest-dev/pytest/issues/11315>`_: The :fixture:`pytester` fixture now uses the :fixture:`monkeypatch` fixture to manage the current working directory.
|
||||
If you use ``pytester`` in combination with :func:`monkeypatch.undo() <pytest.MonkeyPatch.undo>`, the CWD might get restored.
|
||||
Use :func:`monkeypatch.context() <pytest.MonkeyPatch.context>` instead.
|
||||
|
||||
|
||||
- `#11333 <https://github.com/pytest-dev/pytest/issues/11333>`_: Corrected the spelling of ``Config.ArgsSource.INVOCATION_DIR``.
|
||||
The previous spelling ``INCOVATION_DIR`` remains as an alias.
|
||||
|
||||
|
||||
- `#11638 <https://github.com/pytest-dev/pytest/issues/11638>`_: Fixed the selftests to pass correctly if ``FORCE_COLOR``, ``NO_COLOR`` or ``PY_COLORS`` is set in the calling environment.
|
||||
|
||||
pytest 7.4.4 (2023-12-31)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11140 <https://github.com/pytest-dev/pytest/issues/11140>`_: Fix non-string constants at the top of file being detected as docstrings on Python>=3.8.
|
||||
|
||||
|
||||
- `#11572 <https://github.com/pytest-dev/pytest/issues/11572>`_: Handle an edge case where :data:`sys.stderr` and :data:`sys.__stderr__` might already be closed when :ref:`faulthandler` is tearing down.
|
||||
|
||||
|
||||
- `#11710 <https://github.com/pytest-dev/pytest/issues/11710>`_: Fixed tracebacks from collection errors not getting pruned.
|
||||
|
||||
|
||||
- `#7966 <https://github.com/pytest-dev/pytest/issues/7966>`_: Removed unhelpful error message from assertion rewrite mechanism when exceptions are raised in ``__iter__`` methods. Now they are treated un-iterable instead.
|
||||
|
||||
|
||||
|
||||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- `#11091 <https://github.com/pytest-dev/pytest/issues/11091>`_: Updated documentation to refer to hyphenated options: replaced ``--junitxml`` with ``--junit-xml`` and ``--collectonly`` with ``--collect-only``.
|
||||
|
||||
|
||||
pytest 7.4.3 (2023-10-24)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#10447 <https://github.com/pytest-dev/pytest/issues/10447>`_: Markers are now considered in the reverse mro order to ensure base class markers are considered first -- this resolves a regression.
|
||||
|
||||
|
||||
- `#11239 <https://github.com/pytest-dev/pytest/issues/11239>`_: Fixed ``:=`` in asserts impacting unrelated test cases.
|
||||
|
||||
|
||||
- `#11439 <https://github.com/pytest-dev/pytest/issues/11439>`_: Handled an edge case where :data:`sys.stderr` might already be closed when :ref:`faulthandler` is tearing down.
|
||||
|
||||
|
||||
pytest 7.4.2 (2023-09-07)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11237 <https://github.com/pytest-dev/pytest/issues/11237>`_: Fix doctest collection of `functools.cached_property` objects.
|
||||
|
||||
|
||||
- `#11306 <https://github.com/pytest-dev/pytest/issues/11306>`_: Fixed bug using ``--importmode=importlib`` which would cause package ``__init__.py`` files to be imported more than once in some cases.
|
||||
|
||||
|
||||
- `#11367 <https://github.com/pytest-dev/pytest/issues/11367>`_: Fixed bug where `user_properties` where not being saved in the JUnit XML file if a fixture failed during teardown.
|
||||
|
||||
|
||||
- `#11394 <https://github.com/pytest-dev/pytest/issues/11394>`_: Fixed crash when parsing long command line arguments that might be interpreted as files.
|
||||
|
||||
|
||||
|
||||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- `#11391 <https://github.com/pytest-dev/pytest/issues/11391>`_: Improved disclaimer on pytest plugin reference page to better indicate this is an automated, non-curated listing.
|
||||
|
||||
|
||||
pytest 7.4.1 (2023-09-02)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#10337 <https://github.com/pytest-dev/pytest/issues/10337>`_: Fixed bug where fake intermediate modules generated by ``--import-mode=importlib`` would not include the
|
||||
child modules as attributes of the parent modules.
|
||||
|
||||
|
||||
- `#10702 <https://github.com/pytest-dev/pytest/issues/10702>`_: Fixed error assertion handling in :func:`pytest.approx` when ``None`` is an expected or received value when comparing dictionaries.
|
||||
|
||||
|
||||
- `#10811 <https://github.com/pytest-dev/pytest/issues/10811>`_: Fixed issue when using ``--import-mode=importlib`` together with ``--doctest-modules`` that caused modules
|
||||
to be imported more than once, causing problems with modules that have import side effects.
|
||||
|
||||
|
||||
pytest 7.4.0 (2023-06-23)
|
||||
=========================
|
||||
|
||||
@@ -356,7 +1108,7 @@ Improvements
|
||||
|
||||
|
||||
- `#8508 <https://github.com/pytest-dev/pytest/issues/8508>`_: Introduce multiline display for warning matching via :py:func:`pytest.warns` and
|
||||
enhance match comparison for :py:func:`_pytest._code.ExceptionInfo.match` as returned by :py:func:`pytest.raises`.
|
||||
enhance match comparison for :py:func:`pytest.ExceptionInfo.match` as returned by :py:func:`pytest.raises`.
|
||||
|
||||
|
||||
- `#8646 <https://github.com/pytest-dev/pytest/issues/8646>`_: Improve :py:func:`pytest.raises`. Previously passing an empty tuple would give a confusing
|
||||
@@ -365,7 +1117,7 @@ Improvements
|
||||
|
||||
- `#9741 <https://github.com/pytest-dev/pytest/issues/9741>`_: On Python 3.11, use the standard library's :mod:`tomllib` to parse TOML.
|
||||
|
||||
:mod:`tomli` is no longer a dependency on Python 3.11.
|
||||
`tomli` is no longer a dependency on Python 3.11.
|
||||
|
||||
|
||||
- `#9742 <https://github.com/pytest-dev/pytest/issues/9742>`_: Display assertion message without escaped newline characters with ``-vv``.
|
||||
@@ -400,7 +1152,7 @@ Bug Fixes
|
||||
|
||||
When inheriting marks from super-classes, marks from the sub-classes are now ordered before marks from the super-classes, in MRO order. Previously it was the reverse.
|
||||
|
||||
When inheriting marks from super-classes, the `pytestmark` attribute of the sub-class now only contains the marks directly applied to it. Previously, it also contained marks from its super-classes. Please note that this attribute should not normally be accessed directly; use :func:`pytest.Node.iter_markers` instead.
|
||||
When inheriting marks from super-classes, the `pytestmark` attribute of the sub-class now only contains the marks directly applied to it. Previously, it also contained marks from its super-classes. Please note that this attribute should not normally be accessed directly; use :func:`Node.iter_markers <_pytest.nodes.Node.iter_markers>` instead.
|
||||
|
||||
|
||||
- `#9159 <https://github.com/pytest-dev/pytest/issues/9159>`_: Showing inner exceptions by forcing native display in ``ExceptionGroups`` even when using display options other than ``--tb=native``. A temporary step before full implementation of pytest-native display for inner exceptions in ``ExceptionGroups``.
|
||||
@@ -653,7 +1405,7 @@ Bug Fixes
|
||||
- `#9355 <https://github.com/pytest-dev/pytest/issues/9355>`_: Fixed error message prints function decorators when using assert in Python 3.8 and above.
|
||||
|
||||
|
||||
- `#9396 <https://github.com/pytest-dev/pytest/issues/9396>`_: Ensure :attr:`pytest.Config.inifile` is available during the :func:`pytest_cmdline_main <_pytest.hookspec.pytest_cmdline_main>` hook (regression during ``7.0.0rc1``).
|
||||
- `#9396 <https://github.com/pytest-dev/pytest/issues/9396>`_: Ensure `pytest.Config.inifile` is available during the :hook:`pytest_cmdline_main` hook (regression during ``7.0.0rc1``).
|
||||
|
||||
|
||||
|
||||
@@ -798,13 +1550,13 @@ Deprecations
|
||||
- ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
|
||||
|
||||
|
||||
- `#8447 <https://github.com/pytest-dev/pytest/issues/8447>`_: Defining a custom pytest node type which is both an :class:`pytest.Item <Item>` and a :class:`pytest.Collector <Collector>` (e.g. :class:`pytest.File <File>`) now issues a warning.
|
||||
- `#8447 <https://github.com/pytest-dev/pytest/issues/8447>`_: Defining a custom pytest node type which is both an :class:`~pytest.Item` and a :class:`~pytest.Collector` (e.g. :class:`~pytest.File`) now issues a warning.
|
||||
It was never sanely supported and triggers hard to debug errors.
|
||||
|
||||
See :ref:`the deprecation note <diamond-inheritance-deprecated>` for full details.
|
||||
|
||||
|
||||
- `#8592 <https://github.com/pytest-dev/pytest/issues/8592>`_: :hook:`pytest_cmdline_preparse` has been officially deprecated. It will be removed in a future release. Use :hook:`pytest_load_initial_conftests` instead.
|
||||
- `#8592 <https://github.com/pytest-dev/pytest/issues/8592>`_: ``pytest_cmdline_preparse`` has been officially deprecated. It will be removed in a future release. Use :hook:`pytest_load_initial_conftests` instead.
|
||||
|
||||
See :ref:`the deprecation note <cmdline-preparse-deprecated>` for full details.
|
||||
|
||||
@@ -840,7 +1592,7 @@ Features
|
||||
- `#7132 <https://github.com/pytest-dev/pytest/issues/7132>`_: Added two environment variables :envvar:`PYTEST_THEME` and :envvar:`PYTEST_THEME_MODE` to let the users customize the pygments theme used.
|
||||
|
||||
|
||||
- `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: Added :meth:`cache.mkdir() <pytest.Cache.mkdir>`, which is similar to the existing :meth:`cache.makedir() <pytest.Cache.makedir>`,
|
||||
- `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: Added :meth:`cache.mkdir() <pytest.Cache.mkdir>`, which is similar to the existing ``cache.makedir()``,
|
||||
but returns a :class:`pathlib.Path` instead of a legacy ``py.path.local``.
|
||||
|
||||
Added a ``paths`` type to :meth:`parser.addini() <pytest.Parser.addini>`,
|
||||
@@ -866,7 +1618,7 @@ Features
|
||||
- ``pytest.HookRecorder`` for the :class:`HookRecorder <pytest.HookRecorder>` type returned from :class:`~pytest.Pytester`.
|
||||
- ``pytest.RecordedHookCall`` for the :class:`RecordedHookCall <pytest.HookRecorder>` type returned from :class:`~pytest.HookRecorder`.
|
||||
- ``pytest.RunResult`` for the :class:`RunResult <pytest.RunResult>` type returned from :class:`~pytest.Pytester`.
|
||||
- ``pytest.LineMatcher`` for the :class:`LineMatcher <pytest.RunResult>` type used in :class:`~pytest.RunResult` and others.
|
||||
- ``pytest.LineMatcher`` for the :class:`LineMatcher <pytest.LineMatcher>` type used in :class:`~pytest.RunResult` and others.
|
||||
- ``pytest.TestReport`` for the :class:`TestReport <pytest.TestReport>` type used in various hooks.
|
||||
- ``pytest.CollectReport`` for the :class:`CollectReport <pytest.CollectReport>` type used in various hooks.
|
||||
|
||||
@@ -899,7 +1651,7 @@ Features
|
||||
|
||||
|
||||
- `#8251 <https://github.com/pytest-dev/pytest/issues/8251>`_: Implement ``Node.path`` as a ``pathlib.Path``. Both the old ``fspath`` and this new attribute gets set no matter whether ``path`` or ``fspath`` (deprecated) is passed to the constructor. It is a replacement for the ``fspath`` attribute (which represents the same path as ``py.path.local``). While ``fspath`` is not deprecated yet
|
||||
due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`, we expect to deprecate it in a future release.
|
||||
due to the ongoing migration of methods like :meth:`~pytest.Item.reportinfo`, we expect to deprecate it in a future release.
|
||||
|
||||
.. note::
|
||||
The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
|
||||
@@ -931,7 +1683,7 @@ Features
|
||||
See :ref:`plugin-stash` for details.
|
||||
|
||||
|
||||
- `#8953 <https://github.com/pytest-dev/pytest/issues/8953>`_: :class:`RunResult <_pytest.pytester.RunResult>` method :meth:`assert_outcomes <_pytest.pytester.RunResult.assert_outcomes>` now accepts a
|
||||
- `#8953 <https://github.com/pytest-dev/pytest/issues/8953>`_: :class:`~pytest.RunResult` method :meth:`~pytest.RunResult.assert_outcomes` now accepts a
|
||||
``warnings`` argument to assert the total number of warnings captured.
|
||||
|
||||
|
||||
@@ -943,7 +1695,7 @@ Features
|
||||
used.
|
||||
|
||||
|
||||
- `#9113 <https://github.com/pytest-dev/pytest/issues/9113>`_: :class:`RunResult <_pytest.pytester.RunResult>` method :meth:`assert_outcomes <_pytest.pytester.RunResult.assert_outcomes>` now accepts a
|
||||
- `#9113 <https://github.com/pytest-dev/pytest/issues/9113>`_: :class:`~pytest.RunResult` method :meth:`~pytest.RunResult.assert_outcomes` now accepts a
|
||||
``deselected`` argument to assert the total number of deselected tests.
|
||||
|
||||
|
||||
@@ -956,7 +1708,7 @@ Improvements
|
||||
|
||||
- `#7480 <https://github.com/pytest-dev/pytest/issues/7480>`_: A deprecation scheduled to be removed in a major version X (e.g. pytest 7, 8, 9, ...) now uses warning category `PytestRemovedInXWarning`,
|
||||
a subclass of :class:`~pytest.PytestDeprecationWarning`,
|
||||
instead of :class:`PytestDeprecationWarning` directly.
|
||||
instead of :class:`~pytest.PytestDeprecationWarning` directly.
|
||||
|
||||
See :ref:`backwards-compatibility` for more details.
|
||||
|
||||
@@ -995,7 +1747,7 @@ Improvements
|
||||
|
||||
- `#8803 <https://github.com/pytest-dev/pytest/issues/8803>`_: It is now possible to add colors to custom log levels on cli log.
|
||||
|
||||
By using :func:`add_color_level <_pytest.logging.add_color_level>` from a ``pytest_configure`` hook, colors can be added::
|
||||
By using ``add_color_level`` from a :hook:`pytest_configure` hook, colors can be added::
|
||||
|
||||
logging_plugin = config.pluginmanager.get_plugin('logging-plugin')
|
||||
logging_plugin.log_cli_handler.formatter.add_color_level(logging.INFO, 'cyan')
|
||||
@@ -1060,7 +1812,7 @@ Bug Fixes
|
||||
|
||||
- `#8503 <https://github.com/pytest-dev/pytest/issues/8503>`_: :meth:`pytest.MonkeyPatch.syspath_prepend` no longer fails when
|
||||
``setuptools`` is not installed.
|
||||
It now only calls :func:`pkg_resources.fixup_namespace_packages` if
|
||||
It now only calls ``pkg_resources.fixup_namespace_packages`` if
|
||||
``pkg_resources`` was previously imported, because it is not needed otherwise.
|
||||
|
||||
|
||||
@@ -1287,7 +2039,7 @@ Features
|
||||
|
||||
This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
|
||||
|
||||
Internally, the old :class:`Testdir <_pytest.pytester.Testdir>` is now a thin wrapper around :class:`Pytester <_pytest.pytester.Pytester>`, preserving the old interface.
|
||||
Internally, the old ``pytest.Testdir`` is now a thin wrapper around :class:`~pytest.Pytester`, preserving the old interface.
|
||||
|
||||
|
||||
- :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
|
||||
@@ -1325,7 +2077,7 @@ Features
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- :issue:`1265`: Added an ``__str__`` implementation to the :class:`~pytest.pytester.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method.
|
||||
- :issue:`1265`: Added an ``__str__`` implementation to the :class:`~pytest.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method.
|
||||
|
||||
|
||||
- :issue:`2044`: Verbose mode now shows the reason that a test was skipped in the test's terminal line after the "SKIPPED", "XFAIL" or "XPASS".
|
||||
@@ -1389,7 +2141,7 @@ Bug Fixes
|
||||
- :issue:`7911`: Directories created by by :fixture:`tmp_path` and :fixture:`tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
|
||||
|
||||
|
||||
- :issue:`7913`: Fixed a crash or hang in :meth:`pytester.spawn <_pytest.pytester.Pytester.spawn>` when the :mod:`readline` module is involved.
|
||||
- :issue:`7913`: Fixed a crash or hang in :meth:`pytester.spawn <pytest.Pytester.spawn>` when the :mod:`readline` module is involved.
|
||||
|
||||
|
||||
- :issue:`7951`: Fixed handling of recursive symlinks when collecting tests.
|
||||
@@ -1506,7 +2258,7 @@ Deprecations
|
||||
if you use this and want a replacement.
|
||||
|
||||
|
||||
- :issue:`7255`: The :hook:`pytest_warning_captured` hook is deprecated in favor
|
||||
- :issue:`7255`: The ``pytest_warning_captured`` hook is deprecated in favor
|
||||
of :hook:`pytest_warning_recorded`, and will be removed in a future version.
|
||||
|
||||
|
||||
@@ -1534,8 +2286,8 @@ Improvements
|
||||
- :issue:`7572`: When a plugin listed in ``required_plugins`` is missing or an unknown config key is used with ``--strict-config``, a simple error message is now shown instead of a stacktrace.
|
||||
|
||||
|
||||
- :issue:`7685`: Added two new attributes :attr:`rootpath <_pytest.config.Config.rootpath>` and :attr:`inipath <_pytest.config.Config.inipath>` to :class:`Config <_pytest.config.Config>`.
|
||||
These attributes are :class:`pathlib.Path` versions of the existing :attr:`rootdir <_pytest.config.Config.rootdir>` and :attr:`inifile <_pytest.config.Config.inifile>` attributes,
|
||||
- :issue:`7685`: Added two new attributes :attr:`rootpath <pytest.Config.rootpath>` and :attr:`inipath <pytest.Config.inipath>` to :class:`~pytest.Config`.
|
||||
These attributes are :class:`pathlib.Path` versions of the existing ``rootdir`` and ``inifile`` attributes,
|
||||
and should be preferred over them when possible.
|
||||
|
||||
|
||||
@@ -1606,7 +2358,7 @@ Trivial/Internal Changes
|
||||
- :issue:`7587`: The dependency on the ``more-itertools`` package has been removed.
|
||||
|
||||
|
||||
- :issue:`7631`: The result type of :meth:`capfd.readouterr() <_pytest.capture.CaptureFixture.readouterr>` (and similar) is no longer a namedtuple,
|
||||
- :issue:`7631`: The result type of :meth:`capfd.readouterr() <pytest.CaptureFixture.readouterr>` (and similar) is no longer a namedtuple,
|
||||
but should behave like one in all respects. This was done for technical reasons.
|
||||
|
||||
|
||||
@@ -1984,10 +2736,10 @@ Improvements
|
||||
- :issue:`7128`: `pytest --version` now displays just the pytest version, while `pytest --version --version` displays more verbose information including plugins. This is more consistent with how other tools show `--version`.
|
||||
|
||||
|
||||
- :issue:`7133`: :meth:`caplog.set_level() <_pytest.logging.LogCaptureFixture.set_level>` will now override any :confval:`log_level` set via the CLI or configuration file.
|
||||
- :issue:`7133`: :meth:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` will now override any :confval:`log_level` set via the CLI or configuration file.
|
||||
|
||||
|
||||
- :issue:`7159`: :meth:`caplog.set_level() <_pytest.logging.LogCaptureFixture.set_level>` and :meth:`caplog.at_level() <_pytest.logging.LogCaptureFixture.at_level>` no longer affect
|
||||
- :issue:`7159`: :meth:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` and :meth:`caplog.at_level() <pytest.LogCaptureFixture.at_level>` no longer affect
|
||||
the level of logs that are shown in the *Captured log report* report section.
|
||||
|
||||
|
||||
@@ -2082,7 +2834,7 @@ Bug Fixes
|
||||
parameter when Python is called with the ``-bb`` flag.
|
||||
|
||||
|
||||
- :issue:`7143`: Fix :meth:`pytest.File.from_parent` so it forwards extra keyword arguments to the constructor.
|
||||
- :issue:`7143`: Fix :meth:`pytest.File.from_parent <_pytest.nodes.Node.from_parent>` so it forwards extra keyword arguments to the constructor.
|
||||
|
||||
|
||||
- :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
|
||||
@@ -2333,7 +3085,7 @@ Improvements
|
||||
- :issue:`6384`: Make `--showlocals` work also with `--tb=short`.
|
||||
|
||||
|
||||
- :issue:`6653`: Add support for matching lines consecutively with :attr:`LineMatcher <_pytest.pytester.LineMatcher>`'s :func:`~_pytest.pytester.LineMatcher.fnmatch_lines` and :func:`~_pytest.pytester.LineMatcher.re_match_lines`.
|
||||
- :issue:`6653`: Add support for matching lines consecutively with :class:`~pytest.LineMatcher`'s :func:`~pytest.LineMatcher.fnmatch_lines` and :func:`~pytest.LineMatcher.re_match_lines`.
|
||||
|
||||
|
||||
- :issue:`6658`: Code is now highlighted in tracebacks when ``pygments`` is installed.
|
||||
@@ -2401,7 +3153,7 @@ Bug Fixes
|
||||
- :issue:`6597`: Fix node ids which contain a parametrized empty-string variable.
|
||||
|
||||
|
||||
- :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's :func:`testdir.runpytest <_pytest.pytester.Testdir.runpytest>` etc.
|
||||
- :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's ``testdir.runpytest`` etc.
|
||||
|
||||
|
||||
- :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook. This includes quitting from a debugger.
|
||||
@@ -2467,7 +3219,7 @@ Bug Fixes
|
||||
``multiprocessing`` module.
|
||||
|
||||
|
||||
- :issue:`6436`: :class:`FixtureDef <_pytest.fixtures.FixtureDef>` objects now properly register their finalizers with autouse and
|
||||
- :issue:`6436`: :class:`~pytest.FixtureDef` objects now properly register their finalizers with autouse and
|
||||
parameterized fixtures that execute before them in the fixture stack so they are torn
|
||||
down at the right times, and in the right order.
|
||||
|
||||
@@ -2523,7 +3275,7 @@ Improvements
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- :issue:`5914`: pytester: fix :py:func:`~_pytest.pytester.LineMatcher.no_fnmatch_line` when used after positive matching.
|
||||
- :issue:`5914`: pytester: fix :py:func:`~pytest.LineMatcher.no_fnmatch_line` when used after positive matching.
|
||||
|
||||
|
||||
- :issue:`6082`: Fix line detection for doctest samples inside :py:class:`python:property` docstrings, as a workaround to :bpo:`17446`.
|
||||
@@ -2587,8 +3339,8 @@ Features
|
||||
rather than implicitly.
|
||||
|
||||
|
||||
- :issue:`5914`: :fixture:`testdir` learned two new functions, :py:func:`~_pytest.pytester.LineMatcher.no_fnmatch_line` and
|
||||
:py:func:`~_pytest.pytester.LineMatcher.no_re_match_line`.
|
||||
- :issue:`5914`: :fixture:`testdir` learned two new functions, :py:func:`~pytest.LineMatcher.no_fnmatch_line` and
|
||||
:py:func:`~pytest.LineMatcher.no_re_match_line`.
|
||||
|
||||
The functions are used to ensure the captured text *does not* match the given
|
||||
pattern.
|
||||
@@ -6440,7 +7192,7 @@ Changes
|
||||
* fix :issue:`2013`: turn RecordedWarning into ``namedtuple``,
|
||||
to give it a comprehensible repr while preventing unwarranted modification.
|
||||
|
||||
* fix :issue:`2208`: ensure an iteration limit for _pytest.compat.get_real_func.
|
||||
* fix :issue:`2208`: ensure an iteration limit for ``_pytest.compat.get_real_func``.
|
||||
Thanks :user:`RonnyPfannschmidt` for the report and PR.
|
||||
|
||||
* Hooks are now verified after collection is complete, rather than right after loading installed plugins. This
|
||||
|
||||
@@ -15,16 +15,15 @@
|
||||
#
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
# The short X.Y version.
|
||||
import ast
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
from typing import List
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from _pytest import __version__ as version
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import sphinx.application
|
||||
|
||||
@@ -171,6 +170,50 @@ extlinks = {
|
||||
}
|
||||
|
||||
|
||||
nitpicky = True
|
||||
nitpick_ignore = [
|
||||
# TODO (fix in pluggy?)
|
||||
("py:class", "HookCaller"),
|
||||
("py:class", "HookspecMarker"),
|
||||
("py:exc", "PluginValidationError"),
|
||||
# Might want to expose/TODO (https://github.com/pytest-dev/pytest/issues/7469)
|
||||
("py:class", "ExceptionRepr"),
|
||||
("py:class", "Exit"),
|
||||
("py:class", "SubRequest"),
|
||||
("py:class", "SubRequest"),
|
||||
("py:class", "TerminalReporter"),
|
||||
("py:class", "_pytest._code.code.TerminalRepr"),
|
||||
("py:class", "_pytest.fixtures.FixtureFunctionMarker"),
|
||||
("py:class", "_pytest.logging.LogCaptureHandler"),
|
||||
("py:class", "_pytest.mark.structures.ParameterSet"),
|
||||
# Intentionally undocumented/private
|
||||
("py:class", "_pytest._code.code.Traceback"),
|
||||
("py:class", "_pytest._py.path.LocalPath"),
|
||||
("py:class", "_pytest.capture.CaptureResult"),
|
||||
("py:class", "_pytest.compat.NotSetType"),
|
||||
("py:class", "_pytest.python.PyCollector"),
|
||||
("py:class", "_pytest.python.PyobjMixin"),
|
||||
("py:class", "_pytest.python_api.RaisesContext"),
|
||||
("py:class", "_pytest.recwarn.WarningsChecker"),
|
||||
("py:class", "_pytest.reports.BaseReport"),
|
||||
# Undocumented third parties
|
||||
("py:class", "_tracing.TagTracerSub"),
|
||||
("py:class", "warnings.WarningMessage"),
|
||||
# Undocumented type aliases
|
||||
("py:class", "LEGACY_PATH"),
|
||||
("py:class", "_PluggyPlugin"),
|
||||
# TypeVars
|
||||
("py:class", "_pytest._code.code.E"),
|
||||
("py:class", "_pytest.fixtures.FixtureFunction"),
|
||||
("py:class", "_pytest.nodes._NodeType"),
|
||||
("py:class", "_pytest.python_api.E"),
|
||||
("py:class", "_pytest.recwarn.T"),
|
||||
("py:class", "_pytest.runner.TResult"),
|
||||
("py:obj", "_pytest.fixtures.FixtureValue"),
|
||||
("py:obj", "_pytest.stash.T"),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
sys.path.append(os.path.abspath("_themes"))
|
||||
@@ -352,7 +395,7 @@ epub_copyright = "2013, holger krekel et alii"
|
||||
# The format is a list of tuples containing the path and title.
|
||||
# epub_pre_files = []
|
||||
|
||||
# HTML files shat should be inserted after the pages created by sphinx.
|
||||
# HTML files that should be inserted after the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
# epub_post_files = []
|
||||
|
||||
@@ -399,9 +442,10 @@ intersphinx_mapping = {
|
||||
|
||||
def configure_logging(app: "sphinx.application.Sphinx") -> None:
|
||||
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
|
||||
import sphinx.util.logging
|
||||
import logging
|
||||
|
||||
import sphinx.util.logging
|
||||
|
||||
class WarnLogFilter(logging.Filter):
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
"""Ignore warnings about missing include with "only" directive.
|
||||
@@ -451,25 +495,6 @@ def setup(app: "sphinx.application.Sphinx") -> None:
|
||||
|
||||
configure_logging(app)
|
||||
|
||||
# Make Sphinx mark classes with "final" when decorated with @final.
|
||||
# We need this because we import final from pytest._compat, not from
|
||||
# typing (for Python < 3.8 compat), so Sphinx doesn't detect it.
|
||||
# To keep things simple we accept any `@final` decorator.
|
||||
# Ref: https://github.com/pytest-dev/pytest/pull/7780
|
||||
import sphinx.pycode.ast
|
||||
import sphinx.pycode.parser
|
||||
|
||||
original_is_final = sphinx.pycode.parser.VariableCommentPicker.is_final
|
||||
|
||||
def patched_is_final(self, decorators: List[ast.expr]) -> bool:
|
||||
if original_is_final(self, decorators):
|
||||
return True
|
||||
return any(
|
||||
sphinx.pycode.ast.unparse(decorator) == "final" for decorator in decorators
|
||||
)
|
||||
|
||||
sphinx.pycode.parser.VariableCommentPicker.is_final = patched_is_final
|
||||
|
||||
# legacypath.py monkey-patches pytest.Testdir in. Import the file so
|
||||
# that autodoc can discover references to it.
|
||||
import _pytest.legacypath # noqa: F401
|
||||
|
||||
@@ -44,7 +44,6 @@ How-to guides
|
||||
|
||||
how-to/existingtestsuite
|
||||
how-to/unittest
|
||||
how-to/nose
|
||||
how-to/xunit_setup
|
||||
|
||||
how-to/bash-completion
|
||||
|
||||
@@ -19,129 +19,39 @@ Below is a complete list of all pytest features which are considered deprecated.
|
||||
:class:`~pytest.PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
|
||||
|
||||
|
||||
.. _nose-deprecation:
|
||||
.. _import-or-skip-import-error:
|
||||
|
||||
Support for tests written for nose
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``pytest.importorskip`` default behavior regarding :class:`ImportError`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.2
|
||||
.. deprecated:: 8.2
|
||||
|
||||
Support for running tests written for `nose <https://nose.readthedocs.io/en/latest/>`__ is now deprecated.
|
||||
Traditionally :func:`pytest.importorskip` will capture :class:`ImportError`, with the original intent being to skip
|
||||
tests where a dependent module is not installed, for example testing with different dependencies.
|
||||
|
||||
``nose`` has been in maintenance mode-only for years, and maintaining the plugin is not trivial as it spills
|
||||
over the code base (see :issue:`9886` for more details).
|
||||
However some packages might be installed in the system, but are not importable due to
|
||||
some other issue, for example, a compilation error or a broken installation. In those cases :func:`pytest.importorskip`
|
||||
would still silently skip the test, but more often than not users would like to see the unexpected
|
||||
error so the underlying issue can be fixed.
|
||||
|
||||
setup/teardown
|
||||
^^^^^^^^^^^^^^
|
||||
In ``8.2`` the ``exc_type`` parameter has been added, giving users the ability of passing :class:`ModuleNotFoundError`
|
||||
to skip tests only if the module cannot really be found, and not because of some other error.
|
||||
|
||||
One thing that might catch users by surprise is that plain ``setup`` and ``teardown`` methods are not pytest native,
|
||||
they are in fact part of the ``nose`` support.
|
||||
Catching only :class:`ModuleNotFoundError` by default (and letting other errors propagate) would be the best solution,
|
||||
however for backward compatibility, pytest will keep the existing behavior but raise an warning if:
|
||||
|
||||
1. The captured exception is of type :class:`ImportError`, and:
|
||||
2. The user does not pass ``exc_type`` explicitly.
|
||||
|
||||
.. code-block:: python
|
||||
If the import attempt raises :class:`ModuleNotFoundError` (the usual case), then the module is skipped and no
|
||||
warning is emitted.
|
||||
|
||||
class Test:
|
||||
def setup(self):
|
||||
self.resource = make_resource()
|
||||
This way, the usual cases will keep working the same way, while unexpected errors will now issue a warning, with
|
||||
users being able to supress the warning by passing ``exc_type=ImportError`` explicitly.
|
||||
|
||||
def teardown(self):
|
||||
self.resource.close()
|
||||
|
||||
def test_foo(self):
|
||||
...
|
||||
|
||||
def test_bar(self):
|
||||
...
|
||||
|
||||
|
||||
|
||||
Native pytest support uses ``setup_method`` and ``teardown_method`` (see :ref:`xunit-method-setup`), so the above should be changed to:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class Test:
|
||||
def setup_method(self):
|
||||
self.resource = make_resource()
|
||||
|
||||
def teardown_method(self):
|
||||
self.resource.close()
|
||||
|
||||
def test_foo(self):
|
||||
...
|
||||
|
||||
def test_bar(self):
|
||||
...
|
||||
|
||||
|
||||
This is easy to do in an entire code base by doing a simple find/replace.
|
||||
|
||||
@with_setup
|
||||
^^^^^^^^^^^
|
||||
|
||||
Code using `@with_setup <with-setup-nose>`_ such as this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nose.tools import with_setup
|
||||
|
||||
|
||||
def setup_some_resource():
|
||||
...
|
||||
|
||||
|
||||
def teardown_some_resource():
|
||||
...
|
||||
|
||||
|
||||
@with_setup(setup_some_resource, teardown_some_resource)
|
||||
def test_foo():
|
||||
...
|
||||
|
||||
Will also need to be ported to a supported pytest style. One way to do it is using a fixture:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def setup_some_resource():
|
||||
...
|
||||
|
||||
|
||||
def teardown_some_resource():
|
||||
...
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def some_resource():
|
||||
setup_some_resource()
|
||||
yield
|
||||
teardown_some_resource()
|
||||
|
||||
|
||||
def test_foo(some_resource):
|
||||
...
|
||||
|
||||
|
||||
.. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup
|
||||
|
||||
.. _instance-collector-deprecation:
|
||||
|
||||
The ``pytest.Instance`` collector
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionremoved:: 7.0
|
||||
|
||||
The ``pytest.Instance`` collector type has been removed.
|
||||
|
||||
Previously, Python test methods were collected as :class:`~pytest.Class` -> ``Instance`` -> :class:`~pytest.Function`.
|
||||
Now :class:`~pytest.Class` collects the test methods directly.
|
||||
|
||||
Most plugins which reference ``Instance`` do so in order to ignore or skip it,
|
||||
using a check such as ``if isinstance(node, Instance): return``.
|
||||
Such plugins should simply remove consideration of ``Instance`` on pytest>=7.
|
||||
However, to keep such uses working, a dummy type has been instanted in ``pytest.Instance`` and ``_pytest.python.Instance``,
|
||||
and importing it emits a deprecation warning. This will be removed in pytest 8.
|
||||
In ``9.0``, the warning will turn into an error, and in ``9.1`` :func:`pytest.importorskip` will only capture
|
||||
:class:`ModuleNotFoundError` by default and no warnings will be issued anymore -- but users can still capture
|
||||
:class:`ImportError` by passing it to ``exc_type``.
|
||||
|
||||
|
||||
.. _node-ctor-fspath-deprecation:
|
||||
@@ -177,13 +87,12 @@ arguments they only pass on to the superclass.
|
||||
resolved in future versions as we slowly get rid of the :pypi:`py`
|
||||
dependency (see :issue:`9283` for a longer discussion).
|
||||
|
||||
Due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`
|
||||
Due to the ongoing migration of methods like :meth:`~pytest.Item.reportinfo`
|
||||
which still is expected to return a ``py.path.local`` object, nodes still have
|
||||
both ``fspath`` (``py.path.local``) and ``path`` (``pathlib.Path``) attributes,
|
||||
no matter what argument was used in the constructor. We expect to deprecate the
|
||||
``fspath`` attribute in a future release.
|
||||
|
||||
.. _legacy-path-hooks-deprecated:
|
||||
|
||||
Configuring hook specs/impls using markers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -197,13 +106,11 @@ have been available since years and should be used instead.
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.tryfirst
|
||||
def pytest_runtest_call():
|
||||
...
|
||||
def pytest_runtest_call(): ...
|
||||
|
||||
|
||||
# or
|
||||
def pytest_runtest_call():
|
||||
...
|
||||
def pytest_runtest_call(): ...
|
||||
|
||||
|
||||
pytest_runtest_call.tryfirst = True
|
||||
@@ -213,8 +120,7 @@ should be changed to:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.hookimpl(tryfirst=True)
|
||||
def pytest_runtest_call():
|
||||
...
|
||||
def pytest_runtest_call(): ...
|
||||
|
||||
Changed ``hookimpl`` attributes:
|
||||
|
||||
@@ -229,6 +135,8 @@ Changed ``hookwrapper`` attributes:
|
||||
* ``historic``
|
||||
|
||||
|
||||
.. _legacy-path-hooks-deprecated:
|
||||
|
||||
``py.path.local`` arguments for hooks replaced with ``pathlib.Path``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -273,62 +181,6 @@ Directly constructing the following classes is now deprecated:
|
||||
|
||||
These constructors have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.
|
||||
|
||||
.. _cmdline-preparse-deprecated:
|
||||
|
||||
Passing ``msg=`` to ``pytest.skip``, ``pytest.fail`` or ``pytest.exit``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
|
||||
Passing the keyword argument ``msg`` to :func:`pytest.skip`, :func:`pytest.fail` or :func:`pytest.exit`
|
||||
is now deprecated and ``reason`` should be used instead. This change is to bring consistency between these
|
||||
functions and the ``@pytest.mark.skip`` and ``@pytest.mark.xfail`` markers which already accept a ``reason`` argument.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_fail_example():
|
||||
# old
|
||||
pytest.fail(msg="foo")
|
||||
# new
|
||||
pytest.fail(reason="bar")
|
||||
|
||||
|
||||
def test_skip_example():
|
||||
# old
|
||||
pytest.skip(msg="foo")
|
||||
# new
|
||||
pytest.skip(reason="bar")
|
||||
|
||||
|
||||
def test_exit_example():
|
||||
# old
|
||||
pytest.exit(msg="foo")
|
||||
# new
|
||||
pytest.exit(reason="bar")
|
||||
|
||||
|
||||
Implementing the ``pytest_cmdline_preparse`` hook
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
|
||||
Implementing the :hook:`pytest_cmdline_preparse` hook has been officially deprecated.
|
||||
Implement the :hook:`pytest_load_initial_conftests` hook instead.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def pytest_cmdline_preparse(config: Config, args: List[str]) -> None:
|
||||
...
|
||||
|
||||
|
||||
# becomes:
|
||||
|
||||
|
||||
def pytest_load_initial_conftests(
|
||||
early_config: Config, parser: Parser, args: List[str]
|
||||
) -> None:
|
||||
...
|
||||
|
||||
.. _diamond-inheritance-deprecated:
|
||||
|
||||
Diamond inheritance between :class:`pytest.Collector` and :class:`pytest.Item`
|
||||
@@ -336,7 +188,7 @@ Diamond inheritance between :class:`pytest.Collector` and :class:`pytest.Item`
|
||||
|
||||
.. deprecated:: 7.0
|
||||
|
||||
Defining a custom pytest node type which is both an :class:`pytest.Item <Item>` and a :class:`pytest.Collector <Collector>` (e.g. :class:`pytest.File <File>`) now issues a warning.
|
||||
Defining a custom pytest node type which is both an :class:`~pytest.Item` and a :class:`~pytest.Collector` (e.g. :class:`~pytest.File`) now issues a warning.
|
||||
It was never sanely supported and triggers hard to debug errors.
|
||||
|
||||
Some plugins providing linting/code analysis have been using this as a hack.
|
||||
@@ -348,8 +200,8 @@ Instead, a separate collector node should be used, which collects the item. See
|
||||
|
||||
.. _uncooperative-constructors-deprecated:
|
||||
|
||||
Constructors of custom :class:`pytest.Node` subclasses should take ``**kwargs``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Constructors of custom :class:`~_pytest.nodes.Node` subclasses should take ``**kwargs``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
|
||||
@@ -380,28 +232,22 @@ conflicts (such as :class:`pytest.File` now taking ``path`` instead of
|
||||
``fspath``, as :ref:`outlined above <node-ctor-fspath-deprecation>`), a
|
||||
deprecation warning is now raised.
|
||||
|
||||
Backward compatibilities in ``Parser.addoption``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Applying a mark to a fixture function
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 2.4
|
||||
.. deprecated:: 7.4
|
||||
|
||||
Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
|
||||
scheduled for removal in pytest 8 (deprecated since pytest 2.4.0):
|
||||
Applying a mark to a fixture function never had any effect, but it is a common user error.
|
||||
|
||||
- ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
|
||||
- ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.usefixtures("clean_database")
|
||||
@pytest.fixture
|
||||
def user() -> User: ...
|
||||
|
||||
Using ``pytest.warns(None)``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Users expected in this case that the ``usefixtures`` mark would have its intended effect of using the ``clean_database`` fixture when ``user`` was invoked, when in fact it has no effect at all.
|
||||
|
||||
.. deprecated:: 7.0
|
||||
|
||||
:func:`pytest.warns(None) <pytest.warns>` is now deprecated because it was frequently misused.
|
||||
Its correct usage was checking that the code emits at least one warning of any type - like ``pytest.warns()``
|
||||
or ``pytest.warns(Warning)``.
|
||||
|
||||
See :ref:`warns use cases` for examples.
|
||||
Now pytest will issue a warning when it encounters this problem, and will raise an error in the future versions.
|
||||
|
||||
|
||||
Returning non-None value in test functions
|
||||
@@ -444,19 +290,6 @@ The proper fix is to change the `return` to an `assert`:
|
||||
assert foo(a, b) == result
|
||||
|
||||
|
||||
The ``--strict`` command-line option
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 6.2
|
||||
|
||||
The ``--strict`` command-line option has been deprecated in favor of ``--strict-markers``, which
|
||||
better conveys what the option does.
|
||||
|
||||
We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing
|
||||
flag for all strictness related options (``--strict-markers`` and ``--strict-config``
|
||||
at the moment, more might be introduced in the future).
|
||||
|
||||
|
||||
The ``yield_fixture`` function/decorator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -467,12 +300,348 @@ The ``yield_fixture`` function/decorator
|
||||
It has been so for a very long time, so can be search/replaced safely.
|
||||
|
||||
|
||||
Removed Features
|
||||
----------------
|
||||
Removed Features and Breaking Changes
|
||||
-------------------------------------
|
||||
|
||||
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
|
||||
an appropriate period of deprecation has passed.
|
||||
|
||||
Some breaking changes which could not be deprecated are also listed.
|
||||
|
||||
.. _nose-deprecation:
|
||||
|
||||
Support for tests written for nose
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.2
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Support for running tests written for `nose <https://nose.readthedocs.io/en/latest/>`__ is now deprecated.
|
||||
|
||||
``nose`` has been in maintenance mode-only for years, and maintaining the plugin is not trivial as it spills
|
||||
over the code base (see :issue:`9886` for more details).
|
||||
|
||||
setup/teardown
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
One thing that might catch users by surprise is that plain ``setup`` and ``teardown`` methods are not pytest native,
|
||||
they are in fact part of the ``nose`` support.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class Test:
|
||||
def setup(self):
|
||||
self.resource = make_resource()
|
||||
|
||||
def teardown(self):
|
||||
self.resource.close()
|
||||
|
||||
def test_foo(self): ...
|
||||
|
||||
def test_bar(self): ...
|
||||
|
||||
|
||||
|
||||
Native pytest support uses ``setup_method`` and ``teardown_method`` (see :ref:`xunit-method-setup`), so the above should be changed to:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class Test:
|
||||
def setup_method(self):
|
||||
self.resource = make_resource()
|
||||
|
||||
def teardown_method(self):
|
||||
self.resource.close()
|
||||
|
||||
def test_foo(self): ...
|
||||
|
||||
def test_bar(self): ...
|
||||
|
||||
|
||||
This is easy to do in an entire code base by doing a simple find/replace.
|
||||
|
||||
@with_setup
|
||||
^^^^^^^^^^^
|
||||
|
||||
Code using `@with_setup <with-setup-nose>`_ such as this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from nose.tools import with_setup
|
||||
|
||||
|
||||
def setup_some_resource(): ...
|
||||
|
||||
|
||||
def teardown_some_resource(): ...
|
||||
|
||||
|
||||
@with_setup(setup_some_resource, teardown_some_resource)
|
||||
def test_foo(): ...
|
||||
|
||||
Will also need to be ported to a supported pytest style. One way to do it is using a fixture:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def setup_some_resource(): ...
|
||||
|
||||
|
||||
def teardown_some_resource(): ...
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def some_resource():
|
||||
setup_some_resource()
|
||||
yield
|
||||
teardown_some_resource()
|
||||
|
||||
|
||||
def test_foo(some_resource): ...
|
||||
|
||||
|
||||
.. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup
|
||||
|
||||
|
||||
The ``compat_co_firstlineno`` attribute
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Nose inspects this attribute on function objects to allow overriding the function's inferred line number.
|
||||
Pytest no longer respects this attribute.
|
||||
|
||||
|
||||
|
||||
Passing ``msg=`` to ``pytest.skip``, ``pytest.fail`` or ``pytest.exit``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Passing the keyword argument ``msg`` to :func:`pytest.skip`, :func:`pytest.fail` or :func:`pytest.exit`
|
||||
is now deprecated and ``reason`` should be used instead. This change is to bring consistency between these
|
||||
functions and the ``@pytest.mark.skip`` and ``@pytest.mark.xfail`` markers which already accept a ``reason`` argument.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_fail_example():
|
||||
# old
|
||||
pytest.fail(msg="foo")
|
||||
# new
|
||||
pytest.fail(reason="bar")
|
||||
|
||||
|
||||
def test_skip_example():
|
||||
# old
|
||||
pytest.skip(msg="foo")
|
||||
# new
|
||||
pytest.skip(reason="bar")
|
||||
|
||||
|
||||
def test_exit_example():
|
||||
# old
|
||||
pytest.exit(msg="foo")
|
||||
# new
|
||||
pytest.exit(reason="bar")
|
||||
|
||||
|
||||
.. _instance-collector-deprecation:
|
||||
|
||||
The ``pytest.Instance`` collector
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionremoved:: 7.0
|
||||
|
||||
The ``pytest.Instance`` collector type has been removed.
|
||||
|
||||
Previously, Python test methods were collected as :class:`~pytest.Class` -> ``Instance`` -> :class:`~pytest.Function`.
|
||||
Now :class:`~pytest.Class` collects the test methods directly.
|
||||
|
||||
Most plugins which reference ``Instance`` do so in order to ignore or skip it,
|
||||
using a check such as ``if isinstance(node, Instance): return``.
|
||||
Such plugins should simply remove consideration of ``Instance`` on pytest>=7.
|
||||
However, to keep such uses working, a dummy type has been instanted in ``pytest.Instance`` and ``_pytest.python.Instance``,
|
||||
and importing it emits a deprecation warning. This was removed in pytest 8.
|
||||
|
||||
|
||||
Using ``pytest.warns(None)``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
:func:`pytest.warns(None) <pytest.warns>` is now deprecated because it was frequently misused.
|
||||
Its correct usage was checking that the code emits at least one warning of any type - like ``pytest.warns()``
|
||||
or ``pytest.warns(Warning)``.
|
||||
|
||||
See :ref:`warns use cases` for examples.
|
||||
|
||||
|
||||
Backward compatibilities in ``Parser.addoption``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 2.4
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
|
||||
removed in pytest 8 (deprecated since pytest 2.4.0):
|
||||
|
||||
- ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
|
||||
- ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
|
||||
|
||||
|
||||
The ``--strict`` command-line option
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 6.2
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
The ``--strict`` command-line option has been deprecated in favor of ``--strict-markers``, which
|
||||
better conveys what the option does.
|
||||
|
||||
We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing
|
||||
flag for all strictness related options (``--strict-markers`` and ``--strict-config``
|
||||
at the moment, more might be introduced in the future).
|
||||
|
||||
|
||||
.. _cmdline-preparse-deprecated:
|
||||
|
||||
Implementing the ``pytest_cmdline_preparse`` hook
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Implementing the ``pytest_cmdline_preparse`` hook has been officially deprecated.
|
||||
Implement the :hook:`pytest_load_initial_conftests` hook instead.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def pytest_cmdline_preparse(config: Config, args: List[str]) -> None: ...
|
||||
|
||||
|
||||
# becomes:
|
||||
|
||||
|
||||
def pytest_load_initial_conftests(
|
||||
early_config: Config, parser: Parser, args: List[str]
|
||||
) -> None: ...
|
||||
|
||||
|
||||
Collection changes in pytest 8
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Added a new :class:`pytest.Directory` base collection node, which all collector nodes for filesystem directories are expected to subclass.
|
||||
This is analogous to the existing :class:`pytest.File` for file nodes.
|
||||
|
||||
Changed :class:`pytest.Package` to be a subclass of :class:`pytest.Directory`.
|
||||
A ``Package`` represents a filesystem directory which is a Python package,
|
||||
i.e. contains an ``__init__.py`` file.
|
||||
|
||||
:class:`pytest.Package` now only collects files in its own directory; previously it collected recursively.
|
||||
Sub-directories are collected as sub-collector nodes, thus creating a collection tree which mirrors the filesystem hierarchy.
|
||||
|
||||
:attr:`session.name <pytest.Session.name>` is now ``""``; previously it was the rootdir directory name.
|
||||
This matches :attr:`session.nodeid <_pytest.nodes.Node.nodeid>` which has always been `""`.
|
||||
|
||||
Added a new :class:`pytest.Dir` concrete collection node, a subclass of :class:`pytest.Directory`.
|
||||
This node represents a filesystem directory, which is not a :class:`pytest.Package`,
|
||||
i.e. does not contain an ``__init__.py`` file.
|
||||
Similarly to ``Package``, it only collects the files in its own directory,
|
||||
while collecting sub-directories as sub-collector nodes.
|
||||
|
||||
Files and directories are now collected in alphabetical order jointly, unless changed by a plugin.
|
||||
Previously, files were collected before directories.
|
||||
|
||||
The collection tree now contains directories/packages up to the :ref:`rootdir <rootdir>`,
|
||||
for initial arguments that are found within the rootdir.
|
||||
For files outside the rootdir, only the immediate directory/package is collected --
|
||||
note however that collecting from outside the rootdir is discouraged.
|
||||
|
||||
As an example, given the following filesystem tree::
|
||||
|
||||
myroot/
|
||||
pytest.ini
|
||||
top/
|
||||
├── aaa
|
||||
│ └── test_aaa.py
|
||||
├── test_a.py
|
||||
├── test_b
|
||||
│ ├── __init__.py
|
||||
│ └── test_b.py
|
||||
├── test_c.py
|
||||
└── zzz
|
||||
├── __init__.py
|
||||
└── test_zzz.py
|
||||
|
||||
the collection tree, as shown by `pytest --collect-only top/` but with the otherwise-hidden :class:`~pytest.Session` node added for clarity,
|
||||
is now the following::
|
||||
|
||||
<Session>
|
||||
<Dir myroot>
|
||||
<Dir top>
|
||||
<Dir aaa>
|
||||
<Module test_aaa.py>
|
||||
<Function test_it>
|
||||
<Module test_a.py>
|
||||
<Function test_it>
|
||||
<Package test_b>
|
||||
<Module test_b.py>
|
||||
<Function test_it>
|
||||
<Module test_c.py>
|
||||
<Function test_it>
|
||||
<Package zzz>
|
||||
<Module test_zzz.py>
|
||||
<Function test_it>
|
||||
|
||||
Previously, it was::
|
||||
|
||||
<Session>
|
||||
<Module top/test_a.py>
|
||||
<Function test_it>
|
||||
<Module top/test_c.py>
|
||||
<Function test_it>
|
||||
<Module top/aaa/test_aaa.py>
|
||||
<Function test_it>
|
||||
<Package test_b>
|
||||
<Module test_b.py>
|
||||
<Function test_it>
|
||||
<Package zzz>
|
||||
<Module test_zzz.py>
|
||||
<Function test_it>
|
||||
|
||||
Code/plugins which rely on a specific shape of the collection tree might need to update.
|
||||
|
||||
|
||||
:class:`pytest.Package` is no longer a :class:`pytest.Module` or :class:`pytest.File`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionchanged:: 8.0
|
||||
|
||||
The ``Package`` collector node designates a Python package, that is, a directory with an `__init__.py` file.
|
||||
Previously ``Package`` was a subtype of ``pytest.Module`` (which represents a single Python module),
|
||||
the module being the `__init__.py` file.
|
||||
This has been deemed a design mistake (see :issue:`11137` and :issue:`7777` for details).
|
||||
|
||||
The ``path`` property of ``Package`` nodes now points to the package directory instead of the ``__init__.py`` file.
|
||||
|
||||
Note that a ``Module`` node for ``__init__.py`` (which is not a ``Package``) may still exist,
|
||||
if it is picked up during collection (e.g. if you configured :confval:`python_files` to include ``__init__.py`` files).
|
||||
|
||||
|
||||
Collecting ``__init__.py`` files no longer collects package
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Running `pytest pkg/__init__.py` now collects the `pkg/__init__.py` file (module) only.
|
||||
Previously, it collected the entire `pkg` package, including other test files in the directory, but excluding tests in the `__init__.py` file itself
|
||||
(unless :confval:`python_files` was changed to allow `__init__.py` file).
|
||||
|
||||
To collect the entire package, specify just the directory: `pytest pkg`.
|
||||
|
||||
|
||||
The ``pytest.collect`` module
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -596,7 +765,7 @@ By using ``legacy`` you will keep using the legacy/xunit1 format when upgrading
|
||||
pytest 6.0, where the default format will be ``xunit2``.
|
||||
|
||||
In order to let users know about the transition, pytest will issue a warning in case
|
||||
the ``--junitxml`` option is given in the command line but ``junit_family`` is not explicitly
|
||||
the ``--junit-xml`` option is given in the command line but ``junit_family`` is not explicitly
|
||||
configured in ``pytest.ini``.
|
||||
|
||||
Services known to support the ``xunit2`` format:
|
||||
@@ -773,8 +942,7 @@ Applying marks to values of a ``pytest.mark.parametrize`` call is now deprecated
|
||||
(50, 500),
|
||||
],
|
||||
)
|
||||
def test_foo(a, b):
|
||||
...
|
||||
def test_foo(a, b): ...
|
||||
|
||||
This code applies the ``pytest.mark.xfail(reason="flaky")`` mark to the ``(6, 36)`` value of the above parametrization
|
||||
call.
|
||||
@@ -797,8 +965,7 @@ To update the code, use ``pytest.param``:
|
||||
(50, 500),
|
||||
],
|
||||
)
|
||||
def test_foo(a, b):
|
||||
...
|
||||
def test_foo(a, b): ...
|
||||
|
||||
|
||||
.. _pytest_funcarg__ prefix deprecated:
|
||||
@@ -949,15 +1116,13 @@ This is just a matter of renaming the fixture as the API is the same:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_foo(record_xml_property):
|
||||
...
|
||||
def test_foo(record_xml_property): ...
|
||||
|
||||
Change to:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_foo(record_property):
|
||||
...
|
||||
def test_foo(record_property): ...
|
||||
|
||||
|
||||
.. _passing command-line string to pytest.main deprecated:
|
||||
@@ -1119,8 +1284,7 @@ Example of usage:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class MySymbol:
|
||||
...
|
||||
class MySymbol: ...
|
||||
|
||||
|
||||
def pytest_namespace():
|
||||
|
||||
@@ -172,7 +172,7 @@ class TestRaises:
|
||||
raise ValueError("demo error")
|
||||
|
||||
def test_tupleerror(self):
|
||||
a, b = [1] # NOQA
|
||||
a, b = [1] # noqa: F841
|
||||
|
||||
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
||||
items = [1, 2, 3]
|
||||
@@ -180,7 +180,7 @@ class TestRaises:
|
||||
a, b = items.pop()
|
||||
|
||||
def test_some_error(self):
|
||||
if namenotexi: # NOQA
|
||||
if namenotexi: # noqa: F821
|
||||
pass
|
||||
|
||||
def func1(self):
|
||||
|
||||
@@ -2,6 +2,7 @@ import os.path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
mydir = os.path.dirname(__file__)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
|
||||
failure_demo = os.path.join(os.path.dirname(__file__), "failure_demo.py")
|
||||
pytest_plugins = ("pytester",)
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
collect_ignore = ["nonpython"]
|
||||
collect_ignore = ["nonpython", "customdirectory"]
|
||||
|
||||
77
doc/en/example/customdirectory.rst
Normal file
77
doc/en/example/customdirectory.rst
Normal file
@@ -0,0 +1,77 @@
|
||||
.. _`custom directory collectors`:
|
||||
|
||||
Using a custom directory collector
|
||||
====================================================
|
||||
|
||||
By default, pytest collects directories using :class:`pytest.Package`, for directories with ``__init__.py`` files,
|
||||
and :class:`pytest.Dir` for other directories.
|
||||
If you want to customize how a directory is collected, you can write your own :class:`pytest.Directory` collector,
|
||||
and use :hook:`pytest_collect_directory` to hook it up.
|
||||
|
||||
.. _`directory manifest plugin`:
|
||||
|
||||
A basic example for a directory manifest file
|
||||
--------------------------------------------------------------
|
||||
|
||||
Suppose you want to customize how collection is done on a per-directory basis.
|
||||
Here is an example ``conftest.py`` plugin that allows directories to contain a ``manifest.json`` file,
|
||||
which defines how the collection should be done for the directory.
|
||||
In this example, only a simple list of files is supported,
|
||||
however you can imagine adding other keys, such as exclusions and globs.
|
||||
|
||||
.. include:: customdirectory/conftest.py
|
||||
:literal:
|
||||
|
||||
You can create a ``manifest.json`` file and some test files:
|
||||
|
||||
.. include:: customdirectory/tests/manifest.json
|
||||
:literal:
|
||||
|
||||
.. include:: customdirectory/tests/test_first.py
|
||||
:literal:
|
||||
|
||||
.. include:: customdirectory/tests/test_second.py
|
||||
:literal:
|
||||
|
||||
.. include:: customdirectory/tests/test_third.py
|
||||
:literal:
|
||||
|
||||
An you can now execute the test specification:
|
||||
|
||||
.. code-block:: pytest
|
||||
|
||||
customdirectory $ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project/customdirectory
|
||||
configfile: pytest.ini
|
||||
collected 2 items
|
||||
|
||||
tests/test_first.py . [ 50%]
|
||||
tests/test_second.py . [100%]
|
||||
|
||||
============================ 2 passed in 0.12s =============================
|
||||
|
||||
.. regendoc:wipe
|
||||
|
||||
Notice how ``test_three.py`` was not executed, because it is not listed in the manifest.
|
||||
|
||||
You can verify that your custom collector appears in the collection tree:
|
||||
|
||||
.. code-block:: pytest
|
||||
|
||||
customdirectory $ pytest --collect-only
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project/customdirectory
|
||||
configfile: pytest.ini
|
||||
collected 2 items
|
||||
|
||||
<Dir customdirectory>
|
||||
<ManifestDirectory tests>
|
||||
<Module test_first.py>
|
||||
<Function test_1>
|
||||
<Module test_second.py>
|
||||
<Function test_2>
|
||||
|
||||
======================== 2 tests collected in 0.12s ========================
|
||||
28
doc/en/example/customdirectory/conftest.py
Normal file
28
doc/en/example/customdirectory/conftest.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# content of conftest.py
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class ManifestDirectory(pytest.Directory):
|
||||
def collect(self):
|
||||
# The standard pytest behavior is to loop over all `test_*.py` files and
|
||||
# call `pytest_collect_file` on each file. This collector instead reads
|
||||
# the `manifest.json` file and only calls `pytest_collect_file` for the
|
||||
# files defined there.
|
||||
manifest_path = self.path / "manifest.json"
|
||||
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
||||
ihook = self.ihook
|
||||
for file in manifest["files"]:
|
||||
yield from ihook.pytest_collect_file(
|
||||
file_path=self.path / file, parent=self
|
||||
)
|
||||
|
||||
|
||||
@pytest.hookimpl
|
||||
def pytest_collect_directory(path, parent):
|
||||
# Use our custom collector for directories containing a `mainfest.json` file.
|
||||
if path.joinpath("manifest.json").is_file():
|
||||
return ManifestDirectory.from_parent(parent=parent, path=path)
|
||||
# Otherwise fallback to the standard behavior.
|
||||
return None
|
||||
0
doc/en/example/customdirectory/pytest.ini
Normal file
0
doc/en/example/customdirectory/pytest.ini
Normal file
6
doc/en/example/customdirectory/tests/manifest.json
Normal file
6
doc/en/example/customdirectory/tests/manifest.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"files": [
|
||||
"test_first.py",
|
||||
"test_second.py"
|
||||
]
|
||||
}
|
||||
3
doc/en/example/customdirectory/tests/test_first.py
Normal file
3
doc/en/example/customdirectory/tests/test_first.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# content of test_first.py
|
||||
def test_1():
|
||||
pass
|
||||
3
doc/en/example/customdirectory/tests/test_second.py
Normal file
3
doc/en/example/customdirectory/tests/test_second.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# content of test_second.py
|
||||
def test_2():
|
||||
pass
|
||||
3
doc/en/example/customdirectory/tests/test_third.py
Normal file
3
doc/en/example/customdirectory/tests/test_third.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# content of test_third.py
|
||||
def test_3():
|
||||
pass
|
||||
@@ -18,7 +18,6 @@ For basic examples, see
|
||||
- :ref:`Fixtures <fixtures>` for basic fixture/setup examples
|
||||
- :ref:`parametrize` for basic test function parametrization
|
||||
- :ref:`unittest` for basic unittest integration
|
||||
- :ref:`noseintegration` for basic nosetests integration
|
||||
|
||||
The following examples aim at various use cases you might encounter.
|
||||
|
||||
@@ -32,3 +31,4 @@ The following examples aim at various use cases you might encounter.
|
||||
special
|
||||
pythoncollection
|
||||
nonpython
|
||||
customdirectory
|
||||
|
||||
@@ -45,7 +45,7 @@ You can then restrict a test run to only run tests marked with ``webtest``:
|
||||
|
||||
$ pytest -v -m webtest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 4 items / 3 deselected / 1 selected
|
||||
@@ -60,7 +60,7 @@ Or the inverse, running all tests except the webtest ones:
|
||||
|
||||
$ pytest -v -m "not webtest"
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 4 items / 1 deselected / 3 selected
|
||||
@@ -82,7 +82,7 @@ tests based on their module, class, method, or function name:
|
||||
|
||||
$ pytest -v test_server.py::TestClass::test_method
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 1 item
|
||||
@@ -97,7 +97,7 @@ You can also select on the class:
|
||||
|
||||
$ pytest -v test_server.py::TestClass
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 1 item
|
||||
@@ -112,7 +112,7 @@ Or select multiple nodes:
|
||||
|
||||
$ pytest -v test_server.py::TestClass test_server.py::test_send_http
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 2 items
|
||||
@@ -136,7 +136,7 @@ Or select multiple nodes:
|
||||
|
||||
Node IDs for failing tests are displayed in the test summary info
|
||||
when running pytest with the ``-rf`` option. You can also
|
||||
construct Node IDs from the output of ``pytest --collectonly``.
|
||||
construct Node IDs from the output of ``pytest --collect-only``.
|
||||
|
||||
Using ``-k expr`` to select tests based on their name
|
||||
-------------------------------------------------------
|
||||
@@ -156,7 +156,7 @@ The expression matching is now case-insensitive.
|
||||
|
||||
$ pytest -v -k http # running with the above defined example module
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 4 items / 3 deselected / 1 selected
|
||||
@@ -171,7 +171,7 @@ And you can also run all tests except the ones that match the keyword:
|
||||
|
||||
$ pytest -k "not send_http" -v
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 4 items / 1 deselected / 3 selected
|
||||
@@ -188,7 +188,7 @@ Or to select "http" and "quick" tests:
|
||||
|
||||
$ pytest -k "http or quick" -v
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 4 items / 2 deselected / 2 selected
|
||||
@@ -397,7 +397,7 @@ the test needs:
|
||||
|
||||
$ pytest -E stage2
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -411,7 +411,7 @@ and here is one that specifies exactly the environment needed:
|
||||
|
||||
$ pytest -E stage1
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -604,7 +604,7 @@ then you will see two tests skipped and two executed tests as expected:
|
||||
|
||||
$ pytest -rs # this option reports skip reasons
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 4 items
|
||||
|
||||
@@ -620,7 +620,7 @@ Note that if you specify a platform via the marker-command line option like this
|
||||
|
||||
$ pytest -m linux
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 4 items / 3 deselected / 1 selected
|
||||
|
||||
@@ -683,7 +683,7 @@ We can now use the ``-m option`` to select one set:
|
||||
|
||||
$ pytest -m interface --tb=short
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 4 items / 2 deselected / 2 selected
|
||||
|
||||
@@ -709,7 +709,7 @@ or to select both "event" and "interface" tests:
|
||||
|
||||
$ pytest -m "interface or event" --tb=short
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 4 items / 1 deselected / 3 selected
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"""
|
||||
module containing a parametrized tests testing cross-python
|
||||
serialization via the pickle module.
|
||||
"""
|
||||
"""Module containing a parametrized tests testing cross-python serialization
|
||||
via the pickle module."""
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
pythonlist = ["python3.5", "python3.6", "python3.7"]
|
||||
|
||||
pythonlist = ["python3.9", "python3.10", "python3.11"]
|
||||
|
||||
|
||||
@pytest.fixture(params=pythonlist)
|
||||
@@ -33,37 +33,33 @@ class Python:
|
||||
dumpfile = self.picklefile.with_name("dump.py")
|
||||
dumpfile.write_text(
|
||||
textwrap.dedent(
|
||||
r"""
|
||||
rf"""
|
||||
import pickle
|
||||
f = open({!r}, 'wb')
|
||||
s = pickle.dump({!r}, f, protocol=2)
|
||||
f = open({str(self.picklefile)!r}, 'wb')
|
||||
s = pickle.dump({obj!r}, f, protocol=2)
|
||||
f.close()
|
||||
""".format(
|
||||
str(self.picklefile), obj
|
||||
)
|
||||
"""
|
||||
)
|
||||
)
|
||||
subprocess.check_call((self.pythonpath, str(dumpfile)))
|
||||
subprocess.run((self.pythonpath, str(dumpfile)), check=True)
|
||||
|
||||
def load_and_is_true(self, expression):
|
||||
loadfile = self.picklefile.with_name("load.py")
|
||||
loadfile.write_text(
|
||||
textwrap.dedent(
|
||||
r"""
|
||||
rf"""
|
||||
import pickle
|
||||
f = open({!r}, 'rb')
|
||||
f = open({str(self.picklefile)!r}, 'rb')
|
||||
obj = pickle.load(f)
|
||||
f.close()
|
||||
res = eval({!r})
|
||||
res = eval({expression!r})
|
||||
if not res:
|
||||
raise SystemExit(1)
|
||||
""".format(
|
||||
str(self.picklefile), expression
|
||||
)
|
||||
"""
|
||||
)
|
||||
)
|
||||
print(loadfile)
|
||||
subprocess.check_call((self.pythonpath, str(loadfile)))
|
||||
subprocess.run((self.pythonpath, str(loadfile)), check=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("obj", [42, {}, {1: 3}])
|
||||
|
||||
@@ -28,7 +28,7 @@ now execute the test specification:
|
||||
|
||||
nonpython $ pytest test_simple.yaml
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project/nonpython
|
||||
collected 2 items
|
||||
|
||||
@@ -64,7 +64,7 @@ consulted when reporting in ``verbose`` mode:
|
||||
|
||||
nonpython $ pytest -v
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project/nonpython
|
||||
collecting ... collected 2 items
|
||||
@@ -90,7 +90,7 @@ interesting to just look at the collection tree:
|
||||
|
||||
nonpython $ pytest --collect-only
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project/nonpython
|
||||
collected 2 items
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class YamlFile(pytest.File):
|
||||
# We need a yaml parser, e.g. PyYAML.
|
||||
import yaml
|
||||
|
||||
raw = yaml.safe_load(self.path.open())
|
||||
raw = yaml.safe_load(self.path.open(encoding="utf-8"))
|
||||
for name, spec in sorted(raw.items()):
|
||||
yield YamlItem.from_parent(self, name=name, spec=spec)
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
Parametrizing tests
|
||||
=================================================
|
||||
|
||||
.. currentmodule:: _pytest.python
|
||||
|
||||
``pytest`` allows to easily parametrize test functions.
|
||||
For basic docs, see :ref:`parametrize-basics`.
|
||||
|
||||
@@ -160,19 +158,20 @@ objects, they are still using the default pytest representation:
|
||||
|
||||
$ pytest test_time.py --collect-only
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 8 items
|
||||
|
||||
<Module test_time.py>
|
||||
<Function test_timedistance_v0[a0-b0-expected0]>
|
||||
<Function test_timedistance_v0[a1-b1-expected1]>
|
||||
<Function test_timedistance_v1[forward]>
|
||||
<Function test_timedistance_v1[backward]>
|
||||
<Function test_timedistance_v2[20011212-20011211-expected0]>
|
||||
<Function test_timedistance_v2[20011211-20011212-expected1]>
|
||||
<Function test_timedistance_v3[forward]>
|
||||
<Function test_timedistance_v3[backward]>
|
||||
<Dir parametrize.rst-198>
|
||||
<Module test_time.py>
|
||||
<Function test_timedistance_v0[a0-b0-expected0]>
|
||||
<Function test_timedistance_v0[a1-b1-expected1]>
|
||||
<Function test_timedistance_v1[forward]>
|
||||
<Function test_timedistance_v1[backward]>
|
||||
<Function test_timedistance_v2[20011212-20011211-expected0]>
|
||||
<Function test_timedistance_v2[20011211-20011212-expected1]>
|
||||
<Function test_timedistance_v3[forward]>
|
||||
<Function test_timedistance_v3[backward]>
|
||||
|
||||
======================== 8 tests collected in 0.12s ========================
|
||||
|
||||
@@ -185,7 +184,7 @@ A quick port of "testscenarios"
|
||||
Here is a quick port to run tests configured with :pypi:`testscenarios`,
|
||||
an add-on from Robert Collins for the standard unittest framework. We
|
||||
only have to work a bit to construct the correct arguments for pytest's
|
||||
:py:func:`Metafunc.parametrize`:
|
||||
:py:func:`Metafunc.parametrize <pytest.Metafunc.parametrize>`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -222,7 +221,7 @@ this is a fully self-contained example which you can run with:
|
||||
|
||||
$ pytest test_scenarios.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 4 items
|
||||
|
||||
@@ -236,16 +235,17 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia
|
||||
|
||||
$ pytest --collect-only test_scenarios.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 4 items
|
||||
|
||||
<Module test_scenarios.py>
|
||||
<Class TestSampleWithScenarios>
|
||||
<Function test_demo1[basic]>
|
||||
<Function test_demo2[basic]>
|
||||
<Function test_demo1[advanced]>
|
||||
<Function test_demo2[advanced]>
|
||||
<Dir parametrize.rst-198>
|
||||
<Module test_scenarios.py>
|
||||
<Class TestSampleWithScenarios>
|
||||
<Function test_demo1[basic]>
|
||||
<Function test_demo2[basic]>
|
||||
<Function test_demo1[advanced]>
|
||||
<Function test_demo2[advanced]>
|
||||
|
||||
======================== 4 tests collected in 0.12s ========================
|
||||
|
||||
@@ -314,13 +314,14 @@ Let's first see how it looks like at collection time:
|
||||
|
||||
$ pytest test_backends.py --collect-only
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
<Module test_backends.py>
|
||||
<Function test_db_initialized[d1]>
|
||||
<Function test_db_initialized[d2]>
|
||||
<Dir parametrize.rst-198>
|
||||
<Module test_backends.py>
|
||||
<Function test_db_initialized[d1]>
|
||||
<Function test_db_initialized[d2]>
|
||||
|
||||
======================== 2 tests collected in 0.12s ========================
|
||||
|
||||
@@ -412,7 +413,7 @@ The result of this test will be successful:
|
||||
|
||||
$ pytest -v test_indirect_list.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 1 item
|
||||
@@ -483,8 +484,8 @@ argument sets to use for each test function. Let's run it:
|
||||
FAILED test_parametrize.py::TestClass::test_equals[1-2] - assert 1 == 2
|
||||
1 failed, 2 passed in 0.12s
|
||||
|
||||
Indirect parametrization with multiple fixtures
|
||||
--------------------------------------------------------------
|
||||
Parametrization with multiple fixtures
|
||||
--------------------------------------
|
||||
|
||||
Here is a stripped down real-life example of using parametrized
|
||||
testing for testing serialization of objects between different python
|
||||
@@ -502,15 +503,14 @@ Running it results in some skips if we don't have all the python interpreters in
|
||||
.. code-block:: pytest
|
||||
|
||||
. $ pytest -rs -q multipython.py
|
||||
sssssssssssssssssssssssssss [100%]
|
||||
ssssssssssss...ssssssssssss [100%]
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [9] multipython.py:69: 'python3.5' not found
|
||||
SKIPPED [9] multipython.py:69: 'python3.6' not found
|
||||
SKIPPED [9] multipython.py:69: 'python3.7' not found
|
||||
27 skipped in 0.12s
|
||||
SKIPPED [12] multipython.py:65: 'python3.9' not found
|
||||
SKIPPED [12] multipython.py:65: 'python3.11' not found
|
||||
3 passed, 24 skipped in 0.12s
|
||||
|
||||
Indirect parametrization of optional implementations/imports
|
||||
--------------------------------------------------------------------
|
||||
Parametrization of optional implementations/imports
|
||||
---------------------------------------------------
|
||||
|
||||
If you want to compare the outcomes of several implementations of a given
|
||||
API, you can write test functions that receive the already imported implementations
|
||||
@@ -567,7 +567,7 @@ If you run this with reporting for skips enabled:
|
||||
|
||||
$ pytest -rs test_module.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
@@ -628,7 +628,7 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker:
|
||||
|
||||
$ pytest -v -m basic
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 24 items / 21 deselected / 3 selected
|
||||
@@ -657,13 +657,16 @@ Use :func:`pytest.raises` with the
|
||||
:ref:`pytest.mark.parametrize ref` decorator to write parametrized tests
|
||||
in which some tests raise exceptions and others do not.
|
||||
|
||||
It may be helpful to use ``nullcontext`` as a complement to ``raises``.
|
||||
``contextlib.nullcontext`` can be used to test cases that are not expected to
|
||||
raise exceptions but that should result in some value. The value is given as the
|
||||
``enter_result`` parameter, which will be available as the ``with`` statement’s
|
||||
target (``e`` in the example below).
|
||||
|
||||
For example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from contextlib import nullcontext as does_not_raise
|
||||
from contextlib import nullcontext
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -671,16 +674,17 @@ For example:
|
||||
@pytest.mark.parametrize(
|
||||
"example_input,expectation",
|
||||
[
|
||||
(3, does_not_raise()),
|
||||
(2, does_not_raise()),
|
||||
(1, does_not_raise()),
|
||||
(3, nullcontext(2)),
|
||||
(2, nullcontext(3)),
|
||||
(1, nullcontext(6)),
|
||||
(0, pytest.raises(ZeroDivisionError)),
|
||||
],
|
||||
)
|
||||
def test_division(example_input, expectation):
|
||||
"""Test how much I know division."""
|
||||
with expectation:
|
||||
assert (6 / example_input) is not None
|
||||
with expectation as e:
|
||||
assert (6 / example_input) == e
|
||||
|
||||
In the example above, the first three test cases should run unexceptionally,
|
||||
while the fourth should raise ``ZeroDivisionError``.
|
||||
In the example above, the first three test cases should run without any
|
||||
exceptions, while the fourth should raise a``ZeroDivisionError`` exception,
|
||||
which is expected by pytest.
|
||||
|
||||
@@ -147,15 +147,16 @@ The test collection would look like this:
|
||||
|
||||
$ pytest --collect-only
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
configfile: pytest.ini
|
||||
collected 2 items
|
||||
|
||||
<Module check_myapp.py>
|
||||
<Class CheckMyApp>
|
||||
<Function simple_check>
|
||||
<Function complex_check>
|
||||
<Dir pythoncollection.rst-199>
|
||||
<Module check_myapp.py>
|
||||
<Class CheckMyApp>
|
||||
<Function simple_check>
|
||||
<Function complex_check>
|
||||
|
||||
======================== 2 tests collected in 0.12s ========================
|
||||
|
||||
@@ -209,16 +210,18 @@ You can always peek at the collection tree without running tests like this:
|
||||
|
||||
. $ pytest --collect-only pythoncollection.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
configfile: pytest.ini
|
||||
collected 3 items
|
||||
|
||||
<Module CWD/pythoncollection.py>
|
||||
<Function test_function>
|
||||
<Class TestClass>
|
||||
<Function test_method>
|
||||
<Function test_anothermethod>
|
||||
<Dir pythoncollection.rst-199>
|
||||
<Dir CWD>
|
||||
<Module pythoncollection.py>
|
||||
<Function test_function>
|
||||
<Class TestClass>
|
||||
<Function test_method>
|
||||
<Function test_anothermethod>
|
||||
|
||||
======================== 3 tests collected in 0.12s ========================
|
||||
|
||||
@@ -291,7 +294,7 @@ file will be left out:
|
||||
|
||||
$ pytest --collect-only
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
configfile: pytest.ini
|
||||
collected 0 items
|
||||
|
||||
@@ -9,7 +9,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
|
||||
assertion $ pytest failure_demo.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project/assertion
|
||||
collected 44 items
|
||||
|
||||
@@ -80,6 +80,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
def test_eq_text(self):
|
||||
> assert "spam" == "eggs"
|
||||
E AssertionError: assert 'spam' == 'eggs'
|
||||
E
|
||||
E - eggs
|
||||
E + spam
|
||||
|
||||
@@ -91,6 +92,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
def test_eq_similar_text(self):
|
||||
> assert "foo 1 bar" == "foo 2 bar"
|
||||
E AssertionError: assert 'foo 1 bar' == 'foo 2 bar'
|
||||
E
|
||||
E - foo 2 bar
|
||||
E ? ^
|
||||
E + foo 1 bar
|
||||
@@ -104,6 +106,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
def test_eq_multiline_text(self):
|
||||
> assert "foo\nspam\nbar" == "foo\neggs\nbar"
|
||||
E AssertionError: assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
|
||||
E
|
||||
E foo
|
||||
E - eggs
|
||||
E + spam
|
||||
@@ -119,6 +122,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
b = "1" * 100 + "b" + "2" * 100
|
||||
> assert a == b
|
||||
E AssertionError: assert '111111111111...2222222222222' == '111111111111...2222222222222'
|
||||
E
|
||||
E Skipping 90 identical leading characters in diff, use -v to show
|
||||
E Skipping 91 identical trailing characters in diff, use -v to show
|
||||
E - 1111111111b222222222
|
||||
@@ -136,15 +140,15 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
b = "1\n" * 100 + "b" + "2\n" * 100
|
||||
> assert a == b
|
||||
E AssertionError: assert '1\n1\n1\n1\n...n2\n2\n2\n2\n' == '1\n1\n1\n1\n...n2\n2\n2\n2\n'
|
||||
E
|
||||
E Skipping 190 identical leading characters in diff, use -v to show
|
||||
E Skipping 191 identical trailing characters in diff, use -v to show
|
||||
E 1
|
||||
E 1
|
||||
E 1
|
||||
E 1
|
||||
E 1...
|
||||
E
|
||||
E ...Full output truncated (6 lines hidden), use '-vv' to show
|
||||
E ...Full output truncated (7 lines hidden), use '-vv' to show
|
||||
|
||||
failure_demo.py:60: AssertionError
|
||||
_________________ TestSpecialisedExplanations.test_eq_list _________________
|
||||
@@ -154,6 +158,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
def test_eq_list(self):
|
||||
> assert [0, 1, 2] == [0, 1, 3]
|
||||
E assert [0, 1, 2] == [0, 1, 3]
|
||||
E
|
||||
E At index 2 diff: 2 != 3
|
||||
E Use -v to get more diff
|
||||
|
||||
@@ -167,6 +172,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
b = [0] * 100 + [2] + [3] * 100
|
||||
> assert a == b
|
||||
E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...]
|
||||
E
|
||||
E At index 100 diff: 1 != 2
|
||||
E Use -v to get more diff
|
||||
|
||||
@@ -178,6 +184,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
def test_eq_dict(self):
|
||||
> assert {"a": 0, "b": 1, "c": 0} == {"a": 0, "b": 2, "d": 0}
|
||||
E AssertionError: assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0}
|
||||
E
|
||||
E Omitting 1 identical items, use -vv to show
|
||||
E Differing items:
|
||||
E {'b': 1} != {'b': 2}
|
||||
@@ -195,6 +202,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
def test_eq_set(self):
|
||||
> assert {0, 10, 11, 12} == {0, 20, 21}
|
||||
E assert {0, 10, 11, 12} == {0, 20, 21}
|
||||
E
|
||||
E Extra items in the left set:
|
||||
E 10
|
||||
E 11
|
||||
@@ -212,6 +220,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
def test_eq_longer_list(self):
|
||||
> assert [1, 2] == [1, 2, 3]
|
||||
E assert [1, 2] == [1, 2, 3]
|
||||
E
|
||||
E Right contains one more item: 3
|
||||
E Use -v to get more diff
|
||||
|
||||
@@ -233,6 +242,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
text = "some multiline\ntext\nwhich\nincludes foo\nand a\ntail"
|
||||
> assert "foo" not in text
|
||||
E AssertionError: assert 'foo' not in 'some multil...nand a\ntail'
|
||||
E
|
||||
E 'foo' is contained here:
|
||||
E some multiline
|
||||
E text
|
||||
@@ -251,6 +261,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
text = "single foo line"
|
||||
> assert "foo" not in text
|
||||
E AssertionError: assert 'foo' not in 'single foo line'
|
||||
E
|
||||
E 'foo' is contained here:
|
||||
E single foo line
|
||||
E ? +++
|
||||
@@ -264,6 +275,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
text = "head " * 50 + "foo " + "tail " * 20
|
||||
> assert "foo" not in text
|
||||
E AssertionError: assert 'foo' not in 'head head h...l tail tail '
|
||||
E
|
||||
E 'foo' is contained here:
|
||||
E head head foo tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
|
||||
E ? +++
|
||||
@@ -277,6 +289,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
text = "head " * 50 + "f" * 70 + "tail " * 20
|
||||
> assert "f" * 70 not in text
|
||||
E AssertionError: assert 'fffffffffff...ffffffffffff' not in 'head head h...l tail tail '
|
||||
E
|
||||
E 'ffffffffffffffffff...fffffffffffffffffff' is contained here:
|
||||
E head head fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffftail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
|
||||
E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@@ -432,7 +445,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
self = <failure_demo.TestRaises object at 0xdeadbeef0020>
|
||||
|
||||
def test_tupleerror(self):
|
||||
> a, b = [1] # NOQA
|
||||
> a, b = [1] # noqa: F841
|
||||
E ValueError: not enough values to unpack (expected 2, got 1)
|
||||
|
||||
failure_demo.py:175: ValueError
|
||||
@@ -454,7 +467,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
|
||||
self = <failure_demo.TestRaises object at 0xdeadbeef0022>
|
||||
|
||||
def test_some_error(self):
|
||||
> if namenotexi: # NOQA
|
||||
> if namenotexi: # noqa: F821
|
||||
E NameError: name 'namenotexi' is not defined
|
||||
|
||||
failure_demo.py:183: NameError
|
||||
|
||||
@@ -168,7 +168,7 @@ Now we'll get feedback on a bad argument:
|
||||
|
||||
|
||||
If you need to provide more detailed error messages, you can use the
|
||||
``type`` parameter and raise ``pytest.UsageError``:
|
||||
``type`` parameter and raise :exc:`pytest.UsageError`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -232,7 +232,7 @@ directory with the above conftest.py:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 0 items
|
||||
|
||||
@@ -296,7 +296,7 @@ and when running it will see a skipped "slow" test:
|
||||
|
||||
$ pytest -rs # "-rs" means report details on the little 's'
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
@@ -312,7 +312,7 @@ Or run it including the ``slow`` marked test:
|
||||
|
||||
$ pytest --runslow
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
@@ -456,7 +456,7 @@ which will add the string to the test header accordingly:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
project deps: mylib-1.1
|
||||
rootdir: /home/sweet/project
|
||||
collected 0 items
|
||||
@@ -484,7 +484,7 @@ which will add info only when run with "--v":
|
||||
|
||||
$ pytest -v
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
info1: did you know that ...
|
||||
did you?
|
||||
@@ -499,7 +499,7 @@ and nothing when run plainly:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 0 items
|
||||
|
||||
@@ -538,7 +538,7 @@ Now we can profile which test functions execute the slowest:
|
||||
|
||||
$ pytest --durations=3
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 3 items
|
||||
|
||||
@@ -644,7 +644,7 @@ If we run this:
|
||||
|
||||
$ pytest -rx
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 4 items
|
||||
|
||||
@@ -660,6 +660,31 @@ If we run this:
|
||||
E assert 0
|
||||
|
||||
test_step.py:11: AssertionError
|
||||
================================ XFAILURES =================================
|
||||
______________________ TestUserHandling.test_deletion ______________________
|
||||
|
||||
item = <Function test_deletion>
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
if "incremental" in item.keywords:
|
||||
# retrieve the class name of the test
|
||||
cls_name = str(item.cls)
|
||||
# check if a previous test has failed for this class
|
||||
if cls_name in _test_failed_incremental:
|
||||
# retrieve the index of the test (if parametrize is used in combination with incremental)
|
||||
parametrize_index = (
|
||||
tuple(item.callspec.indices.values())
|
||||
if hasattr(item, "callspec")
|
||||
else ()
|
||||
)
|
||||
# retrieve the name of the first test function to fail for this class name and index
|
||||
test_name = _test_failed_incremental[cls_name].get(parametrize_index, None)
|
||||
# if name found, test has failed for the combination of class name & test name
|
||||
if test_name is not None:
|
||||
> pytest.xfail(f"previous test failed ({test_name})")
|
||||
E _pytest.outcomes.XFailed: previous test failed (test_modification)
|
||||
|
||||
conftest.py:47: XFailed
|
||||
========================= short test summary info ==========================
|
||||
XFAIL test_step.py::TestUserHandling::test_deletion - reason: previous test failed (test_modification)
|
||||
================== 1 failed, 2 passed, 1 xfailed in 0.12s ==================
|
||||
@@ -726,14 +751,14 @@ We can run this:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 7 items
|
||||
|
||||
test_step.py .Fx. [ 57%]
|
||||
a/test_db.py F [ 71%]
|
||||
a/test_db2.py F [ 85%]
|
||||
b/test_error.py E [100%]
|
||||
a/test_db.py F [ 14%]
|
||||
a/test_db2.py F [ 28%]
|
||||
b/test_error.py E [ 42%]
|
||||
test_step.py .Fx. [100%]
|
||||
|
||||
================================== ERRORS ==================================
|
||||
_______________________ ERROR at setup of test_root ________________________
|
||||
@@ -745,39 +770,39 @@ We can run this:
|
||||
|
||||
/home/sweet/project/b/test_error.py:1
|
||||
================================= FAILURES =================================
|
||||
_________________________________ test_a1 __________________________________
|
||||
|
||||
db = <conftest.DB object at 0xdeadbeef0002>
|
||||
|
||||
def test_a1(db):
|
||||
> assert 0, db # to show value
|
||||
E AssertionError: <conftest.DB object at 0xdeadbeef0002>
|
||||
E assert 0
|
||||
|
||||
a/test_db.py:2: AssertionError
|
||||
_________________________________ test_a2 __________________________________
|
||||
|
||||
db = <conftest.DB object at 0xdeadbeef0002>
|
||||
|
||||
def test_a2(db):
|
||||
> assert 0, db # to show value
|
||||
E AssertionError: <conftest.DB object at 0xdeadbeef0002>
|
||||
E assert 0
|
||||
|
||||
a/test_db2.py:2: AssertionError
|
||||
____________________ TestUserHandling.test_modification ____________________
|
||||
|
||||
self = <test_step.TestUserHandling object at 0xdeadbeef0002>
|
||||
self = <test_step.TestUserHandling object at 0xdeadbeef0003>
|
||||
|
||||
def test_modification(self):
|
||||
> assert 0
|
||||
E assert 0
|
||||
|
||||
test_step.py:11: AssertionError
|
||||
_________________________________ test_a1 __________________________________
|
||||
|
||||
db = <conftest.DB object at 0xdeadbeef0003>
|
||||
|
||||
def test_a1(db):
|
||||
> assert 0, db # to show value
|
||||
E AssertionError: <conftest.DB object at 0xdeadbeef0003>
|
||||
E assert 0
|
||||
|
||||
a/test_db.py:2: AssertionError
|
||||
_________________________________ test_a2 __________________________________
|
||||
|
||||
db = <conftest.DB object at 0xdeadbeef0003>
|
||||
|
||||
def test_a2(db):
|
||||
> assert 0, db # to show value
|
||||
E AssertionError: <conftest.DB object at 0xdeadbeef0003>
|
||||
E assert 0
|
||||
|
||||
a/test_db2.py:2: AssertionError
|
||||
========================= short test summary info ==========================
|
||||
FAILED test_step.py::TestUserHandling::test_modification - assert 0
|
||||
FAILED a/test_db.py::test_a1 - AssertionError: <conftest.DB object at 0x7...
|
||||
FAILED a/test_db2.py::test_a2 - AssertionError: <conftest.DB object at 0x...
|
||||
FAILED test_step.py::TestUserHandling::test_modification - assert 0
|
||||
ERROR b/test_error.py::test_root
|
||||
============= 3 failed, 2 passed, 1 xfailed, 1 error in 0.12s ==============
|
||||
|
||||
@@ -808,16 +833,15 @@ case we just write some information out to a ``failures`` file:
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||
@pytest.hookimpl(wrapper=True, tryfirst=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
# execute all other hooks to obtain the report object
|
||||
outcome = yield
|
||||
rep = outcome.get_result()
|
||||
rep = yield
|
||||
|
||||
# we only look at actual failing test calls, not setup/teardown
|
||||
if rep.when == "call" and rep.failed:
|
||||
mode = "a" if os.path.exists("failures") else "w"
|
||||
with open("failures", mode) as f:
|
||||
with open("failures", mode, encoding="utf-8") as f:
|
||||
# let's also access a fixture for the fun of it
|
||||
if "tmp_path" in item.fixturenames:
|
||||
extra = " ({})".format(item.funcargs["tmp_path"])
|
||||
@@ -826,6 +850,8 @@ case we just write some information out to a ``failures`` file:
|
||||
|
||||
f.write(rep.nodeid + extra + "\n")
|
||||
|
||||
return rep
|
||||
|
||||
|
||||
if you then have failing tests:
|
||||
|
||||
@@ -845,7 +871,7 @@ and run them:
|
||||
|
||||
$ pytest test_module.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
@@ -899,16 +925,17 @@ here is a little example implemented via a local plugin:
|
||||
phase_report_key = StashKey[Dict[str, CollectReport]]()
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||
@pytest.hookimpl(wrapper=True, tryfirst=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
# execute all other hooks to obtain the report object
|
||||
outcome = yield
|
||||
rep = outcome.get_result()
|
||||
rep = yield
|
||||
|
||||
# store test results for each phase of a call, which can
|
||||
# be "setup", "call", "teardown"
|
||||
item.stash.setdefault(phase_report_key, {})[rep.when] = rep
|
||||
|
||||
return rep
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def something(request):
|
||||
@@ -953,7 +980,7 @@ and run it:
|
||||
|
||||
$ pytest -s test_module.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 3 items
|
||||
|
||||
@@ -1088,4 +1115,4 @@ application with standard ``pytest`` command-line options:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./app_main --pytest --verbose --tb=long --junitxml=results.xml test-suite/
|
||||
./app_main --pytest --verbose --tb=long --junit=xml=results.xml test-suite/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
|
||||
|
||||
xfail = pytest.mark.xfail
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ a function/method call.
|
||||
|
||||
**Assert** is where we look at that resulting state and check if it looks how
|
||||
we'd expect after the dust has settled. It's where we gather evidence to say the
|
||||
behavior does or does not aligns with what we expect. The ``assert`` in our test
|
||||
behavior does or does not align with what we expect. The ``assert`` in our test
|
||||
is where we take that measurement/observation and apply our judgement to it. If
|
||||
something should be green, we'd say ``assert thing == "green"``.
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ style of setup/teardown functions:
|
||||
In addition, pytest continues to support :ref:`xunitsetup`. You can mix
|
||||
both styles, moving incrementally from classic to new style, as you
|
||||
prefer. You can also start out from existing :ref:`unittest.TestCase
|
||||
style <unittest.TestCase>` or :ref:`nose based <nosestyle>` projects.
|
||||
style <unittest.TestCase>`.
|
||||
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ A note about fixture cleanup
|
||||
----------------------------
|
||||
|
||||
pytest does not do any special processing for :data:`SIGTERM <signal.SIGTERM>` and
|
||||
:data:`SIGQUIT <signal.SIGQUIT>` signals (:data:`SIGINT <signal.SIGINT>` is handled naturally
|
||||
``SIGQUIT`` signals (:data:`SIGINT <signal.SIGINT>` is handled naturally
|
||||
by the Python runtime via :class:`KeyboardInterrupt`), so fixtures that manage external resources which are important
|
||||
to be cleared when the Python process is terminated (by those signals) might leak resources.
|
||||
|
||||
|
||||
@@ -52,10 +52,9 @@ Plugins
|
||||
|
||||
Rerunning any failed tests can mitigate the negative effects of flaky tests by giving them additional chances to pass, so that the overall build does not fail. Several pytest plugins support this:
|
||||
|
||||
* `flaky <https://github.com/box/flaky>`_
|
||||
* `pytest-flakefinder <https://github.com/dropbox/pytest-flakefinder>`_ - `blog post <https://blogs.dropbox.com/tech/2016/03/open-sourcing-pytest-tools/>`_
|
||||
* `pytest-rerunfailures <https://github.com/pytest-dev/pytest-rerunfailures>`_
|
||||
* `pytest-replay <https://github.com/ESSS/pytest-replay>`_: This plugin helps to reproduce locally crashes or flaky tests observed during CI runs.
|
||||
* `pytest-flakefinder <https://github.com/dropbox/pytest-flakefinder>`_ - `blog post <https://blogs.dropbox.com/tech/2016/03/open-sourcing-pytest-tools/>`_
|
||||
|
||||
Plugins to deliberately randomize tests can help expose tests with state problems:
|
||||
|
||||
@@ -106,7 +105,7 @@ This is a limited list, please submit an issue or pull request to expand it!
|
||||
* Gao, Zebao, Yalan Liang, Myra B. Cohen, Atif M. Memon, and Zhen Wang. "Making system user interactive tests repeatable: When and what should we control?." In *Software Engineering (ICSE), 2015 IEEE/ACM 37th IEEE International Conference on*, vol. 1, pp. 55-65. IEEE, 2015. `PDF <http://www.cs.umd.edu/~atif/pubs/gao-icse15.pdf>`__
|
||||
* Palomba, Fabio, and Andy Zaidman. "Does refactoring of test smells induce fixing flaky tests?." In *Software Maintenance and Evolution (ICSME), 2017 IEEE International Conference on*, pp. 1-12. IEEE, 2017. `PDF in Google Drive <https://drive.google.com/file/d/10HdcCQiuQVgW3yYUJD-TSTq1NbYEprl0/view>`__
|
||||
* Bell, Jonathan, Owolabi Legunsen, Michael Hilton, Lamyaa Eloussi, Tifany Yung, and Darko Marinov. "DeFlaker: Automatically detecting flaky tests." In *Proceedings of the 2018 International Conference on Software Engineering*. 2018. `PDF <https://www.jonbell.net/icse18-deflaker.pdf>`__
|
||||
|
||||
* Dutta, Saikat and Shi, August and Choudhary, Rutvik and Zhang, Zhekun and Jain, Aryaman and Misailovic, Sasa. "Detecting flaky tests in probabilistic and machine learning applications." In *Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA)*, pp. 211-224. ACM, 2020. `PDF <https://www.cs.cornell.edu/~saikatd/papers/flash-issta20.pdf>`__
|
||||
|
||||
Resources
|
||||
^^^^^^^^^
|
||||
|
||||
@@ -60,8 +60,10 @@ Within Python modules, ``pytest`` also discovers tests using the standard
|
||||
:ref:`unittest.TestCase <unittest.TestCase>` subclassing technique.
|
||||
|
||||
|
||||
Choosing a test layout / import rules
|
||||
-------------------------------------
|
||||
.. _`test layout`:
|
||||
|
||||
Choosing a test layout
|
||||
----------------------
|
||||
|
||||
``pytest`` supports two common test layouts:
|
||||
|
||||
|
||||
@@ -10,19 +10,27 @@ Import modes
|
||||
|
||||
pytest as a testing framework needs to import test modules and ``conftest.py`` files for execution.
|
||||
|
||||
Importing files in Python (at least until recently) is a non-trivial processes, often requiring
|
||||
changing :data:`sys.path`. Some aspects of the
|
||||
Importing files in Python is a non-trivial processes, so aspects of the
|
||||
import process can be controlled through the ``--import-mode`` command-line flag, which can assume
|
||||
these values:
|
||||
|
||||
* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
|
||||
of :py:data:`sys.path` if not already there, and then imported with the :func:`importlib.import_module <importlib.import_module>` function.
|
||||
.. _`import-mode-prepend`:
|
||||
|
||||
This requires test module names to be unique when the test directory tree is not arranged in
|
||||
packages, because the modules will put in :py:data:`sys.modules` after importing.
|
||||
* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
|
||||
of :py:data:`sys.path` if not already there, and then imported with
|
||||
the :func:`importlib.import_module <importlib.import_module>` function.
|
||||
|
||||
It is highly recommended to arrange your test modules as packages by adding ``__init__.py`` files to your directories
|
||||
containing tests. This will make the tests part of a proper Python package, allowing pytest to resolve their full
|
||||
name (for example ``tests.core.test_core`` for ``test_core.py`` inside the ``tests.core`` package).
|
||||
|
||||
If the test directory tree is not arranged as packages, then each test file needs to have a unique name
|
||||
compared to the other test files, otherwise pytest will raise an error if it finds two tests with the same name.
|
||||
|
||||
This is the classic mechanism, dating back from the time Python 2 was still supported.
|
||||
|
||||
.. _`import-mode-append`:
|
||||
|
||||
* ``append``: the directory containing each module is appended to the end of :py:data:`sys.path` if not already
|
||||
there, and imported with :func:`importlib.import_module <importlib.import_module>`.
|
||||
|
||||
@@ -38,32 +46,78 @@ these values:
|
||||
the tests will run against the installed version
|
||||
of ``pkg_under_test`` when ``--import-mode=append`` is used whereas
|
||||
with ``prepend`` they would pick up the local version. This kind of confusion is why
|
||||
we advocate for using :ref:`src <src-layout>` layouts.
|
||||
we advocate for using :ref:`src-layouts <src-layout>`.
|
||||
|
||||
Same as ``prepend``, requires test module names to be unique when the test directory tree is
|
||||
not arranged in packages, because the modules will put in :py:data:`sys.modules` after importing.
|
||||
|
||||
* ``importlib``: new in pytest-6.0, this mode uses more fine control mechanisms provided by :mod:`importlib` to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
|
||||
.. _`import-mode-importlib`:
|
||||
|
||||
For this reason this doesn't require test module names to be unique.
|
||||
* ``importlib``: this mode uses more fine control mechanisms provided by :mod:`importlib` to import test modules, without changing :py:data:`sys.path`.
|
||||
|
||||
One drawback however is that test modules are non-importable by each other. Also, utility
|
||||
modules in the tests directories are not automatically importable because the tests directory is no longer
|
||||
added to :py:data:`sys.path`.
|
||||
Advantages of this mode:
|
||||
|
||||
Initially we intended to make ``importlib`` the default in future releases, however it is clear now that
|
||||
it has its own set of drawbacks so the default will remain ``prepend`` for the foreseeable future.
|
||||
* pytest will not change :py:data:`sys.path` at all.
|
||||
* Test module names do not need to be unique -- pytest will generate a unique name automatically based on the ``rootdir``.
|
||||
|
||||
Disadvantages:
|
||||
|
||||
* Test modules can't import each other.
|
||||
* Testing utility modules in the tests directories (for example a ``tests.helpers`` module containing test-related functions/classes)
|
||||
are not importable. The recommendation in this case it to place testing utility modules together with the application/library
|
||||
code, for example ``app.testing.helpers``.
|
||||
|
||||
Important: by "test utility modules" we mean functions/classes which are imported by
|
||||
other tests directly; this does not include fixtures, which should be placed in ``conftest.py`` files, along
|
||||
with the test modules, and are discovered automatically by pytest.
|
||||
|
||||
It works like this:
|
||||
|
||||
1. Given a certain module path, for example ``tests/core/test_models.py``, derives a canonical name
|
||||
like ``tests.core.test_models`` and tries to import it.
|
||||
|
||||
For non-test modules this will work if they are accessible via :py:data:`sys.path`, so
|
||||
for example ``.env/lib/site-packages/app/core.py`` will be importable as ``app.core``.
|
||||
This is happens when plugins import non-test modules (for example doctesting).
|
||||
|
||||
If this step succeeds, the module is returned.
|
||||
|
||||
For test modules, unless they are reachable from :py:data:`sys.path`, this step will fail.
|
||||
|
||||
2. If the previous step fails, we import the module directly using ``importlib`` facilities, which lets us import it without
|
||||
changing :py:data:`sys.path`.
|
||||
|
||||
Because Python requires the module to also be available in :py:data:`sys.modules`, pytest derives a unique name for it based
|
||||
on its relative location from the ``rootdir``, and adds the module to :py:data:`sys.modules`.
|
||||
|
||||
For example, ``tests/core/test_models.py`` will end up being imported as the module ``tests.core.test_models``.
|
||||
|
||||
.. versionadded:: 6.0
|
||||
|
||||
.. note::
|
||||
|
||||
Initially we intended to make ``importlib`` the default in future releases, however it is clear now that
|
||||
it has its own set of drawbacks so the default will remain ``prepend`` for the foreseeable future.
|
||||
|
||||
.. note::
|
||||
|
||||
By default, pytest will not attempt to resolve namespace packages automatically, but that can
|
||||
be changed via the :confval:`consider_namespace_packages` configuration variable.
|
||||
|
||||
.. seealso::
|
||||
|
||||
The :confval:`pythonpath` configuration variable.
|
||||
|
||||
The :confval:`consider_namespace_packages` configuration variable.
|
||||
|
||||
:ref:`test layout`.
|
||||
|
||||
|
||||
``prepend`` and ``append`` import modes scenarios
|
||||
-------------------------------------------------
|
||||
|
||||
Here's a list of scenarios when using ``prepend`` or ``append`` import modes where pytest needs to
|
||||
change ``sys.path`` in order to import test modules or ``conftest.py`` files, and the issues users
|
||||
change :py:data:`sys.path` in order to import test modules or ``conftest.py`` files, and the issues users
|
||||
might encounter because of that.
|
||||
|
||||
Test modules / ``conftest.py`` files inside packages
|
||||
@@ -92,7 +146,7 @@ pytest will find ``foo/bar/tests/test_foo.py`` and realize it is part of a packa
|
||||
there's an ``__init__.py`` file in the same folder. It will then search upwards until it can find the
|
||||
last folder which still contains an ``__init__.py`` file in order to find the package *root* (in
|
||||
this case ``foo/``). To load the module, it will insert ``root/`` to the front of
|
||||
``sys.path`` (if not there already) in order to load
|
||||
:py:data:`sys.path` (if not there already) in order to load
|
||||
``test_foo.py`` as the *module* ``foo.bar.tests.test_foo``.
|
||||
|
||||
The same logic applies to the ``conftest.py`` file: it will be imported as ``foo.conftest`` module.
|
||||
@@ -122,8 +176,8 @@ When executing:
|
||||
|
||||
pytest will find ``foo/bar/tests/test_foo.py`` and realize it is NOT part of a package given that
|
||||
there's no ``__init__.py`` file in the same folder. It will then add ``root/foo/bar/tests`` to
|
||||
``sys.path`` in order to import ``test_foo.py`` as the *module* ``test_foo``. The same is done
|
||||
with the ``conftest.py`` file by adding ``root/foo`` to ``sys.path`` to import it as ``conftest``.
|
||||
:py:data:`sys.path` in order to import ``test_foo.py`` as the *module* ``test_foo``. The same is done
|
||||
with the ``conftest.py`` file by adding ``root/foo`` to :py:data:`sys.path` to import it as ``conftest``.
|
||||
|
||||
For this reason this layout cannot have test modules with the same name, as they all will be
|
||||
imported in the global import namespace.
|
||||
@@ -136,7 +190,7 @@ Invoking ``pytest`` versus ``python -m pytest``
|
||||
-----------------------------------------------
|
||||
|
||||
Running pytest with ``pytest [...]`` instead of ``python -m pytest [...]`` yields nearly
|
||||
equivalent behaviour, except that the latter will add the current directory to ``sys.path``, which
|
||||
equivalent behaviour, except that the latter will add the current directory to :py:data:`sys.path`, which
|
||||
is standard ``python`` behavior.
|
||||
|
||||
See also :ref:`invoke-python`.
|
||||
|
||||
@@ -11,8 +11,6 @@ funcarg mechanism, see :ref:`historical funcargs and pytest.funcargs`.
|
||||
If you are new to pytest, then you can simply ignore this
|
||||
section and read the other sections.
|
||||
|
||||
.. currentmodule:: _pytest
|
||||
|
||||
Shortcomings of the previous ``pytest_funcarg__`` mechanism
|
||||
--------------------------------------------------------------
|
||||
|
||||
@@ -46,7 +44,7 @@ There are several limitations and difficulties with this approach:
|
||||
|
||||
2. parametrizing the "db" resource is not straight forward:
|
||||
you need to apply a "parametrize" decorator or implement a
|
||||
:py:func:`~hookspec.pytest_generate_tests` hook
|
||||
:hook:`pytest_generate_tests` hook
|
||||
calling :py:func:`~pytest.Metafunc.parametrize` which
|
||||
performs parametrization at the places where the resource
|
||||
is used. Moreover, you need to modify the factory to use an
|
||||
@@ -94,15 +92,14 @@ Direct parametrization of funcarg resource factories
|
||||
|
||||
Previously, funcarg factories could not directly cause parametrization.
|
||||
You needed to specify a ``@parametrize`` decorator on your test function
|
||||
or implement a ``pytest_generate_tests`` hook to perform
|
||||
or implement a :hook:`pytest_generate_tests` hook to perform
|
||||
parametrization, i.e. calling a test multiple times with different value
|
||||
sets. pytest-2.3 introduces a decorator for use on the factory itself:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.fixture(params=["mysql", "pg"])
|
||||
def db(request):
|
||||
... # use request.param
|
||||
def db(request): ... # use request.param
|
||||
|
||||
Here the factory will be invoked twice (with the respective "mysql"
|
||||
and "pg" values set as ``request.param`` attributes) and all of
|
||||
@@ -143,8 +140,7 @@ argument:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.fixture()
|
||||
def db(request):
|
||||
...
|
||||
def db(request): ...
|
||||
|
||||
The name under which the funcarg resource can be requested is ``db``.
|
||||
|
||||
@@ -153,8 +149,7 @@ aka:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def pytest_funcarg__db(request):
|
||||
...
|
||||
def pytest_funcarg__db(request): ...
|
||||
|
||||
|
||||
But it is then not possible to define scoping and parametrization.
|
||||
|
||||
@@ -9,7 +9,7 @@ Get Started
|
||||
Install ``pytest``
|
||||
----------------------------------------
|
||||
|
||||
``pytest`` requires: Python 3.7+ or PyPy3.
|
||||
``pytest`` requires: Python 3.8+ or PyPy3.
|
||||
|
||||
1. Run the following command in your command line:
|
||||
|
||||
@@ -22,7 +22,7 @@ Install ``pytest``
|
||||
.. code-block:: bash
|
||||
|
||||
$ pytest --version
|
||||
pytest 7.4.0
|
||||
pytest 8.2.0
|
||||
|
||||
.. _`simpletest`:
|
||||
|
||||
@@ -47,7 +47,7 @@ The test
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -97,6 +97,30 @@ Use the :ref:`raises <assertraises>` helper to assert that some code raises an e
|
||||
with pytest.raises(SystemExit):
|
||||
f()
|
||||
|
||||
You can also use the context provided by :ref:`raises <assertraises>` to
|
||||
assert that an expected exception is part of a raised :class:`ExceptionGroup`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# content of test_exceptiongroup.py
|
||||
import pytest
|
||||
|
||||
|
||||
def f():
|
||||
raise ExceptionGroup(
|
||||
"Group message",
|
||||
[
|
||||
RuntimeError(),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def test_exception_in_group():
|
||||
with pytest.raises(ExceptionGroup) as excinfo:
|
||||
f()
|
||||
assert excinfo.group_contains(RuntimeError)
|
||||
assert not excinfo.group_contains(TypeError)
|
||||
|
||||
Execute the test function with “quiet” reporting mode:
|
||||
|
||||
.. code-block:: pytest
|
||||
|
||||
@@ -112,7 +112,7 @@ More details can be found in the :pull:`original PR <3317>`.
|
||||
.. note::
|
||||
|
||||
in a future major release of pytest we will introduce class based markers,
|
||||
at which point markers will no longer be limited to instances of :py:class:`~_pytest.mark.Mark`.
|
||||
at which point markers will no longer be limited to instances of :py:class:`~pytest.Mark`.
|
||||
|
||||
|
||||
cache plugin integrated into the core
|
||||
@@ -227,8 +227,7 @@ to use strings:
|
||||
|
||||
|
||||
@pytest.mark.skipif("sys.version_info >= (3,3)")
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
During test function setup the skipif condition is evaluated by calling
|
||||
``eval('sys.version_info >= (3,0)', namespace)``. The namespace contains
|
||||
@@ -262,8 +261,7 @@ configuration value which you might have added:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.skipif("not config.getvalue('db')")
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
The equivalent with "boolean conditions" is:
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ you will see the return value of the function call:
|
||||
|
||||
$ pytest test_assert1.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -54,14 +54,13 @@ operators. (See :ref:`tbreportdemo`). This allows you to use the
|
||||
idiomatic python constructs without boilerplate code while not losing
|
||||
introspection information.
|
||||
|
||||
However, if you specify a message with the assertion like this:
|
||||
If a message is specified with the assertion like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
assert a % 2 == 0, "value was odd, should be even"
|
||||
|
||||
then no assertion introspection takes places at all and the message
|
||||
will be simply shown in the traceback.
|
||||
it is printed alongside the assertion introspection in the traceback.
|
||||
|
||||
See :ref:`assert-details` for more information on assertion introspection.
|
||||
|
||||
@@ -99,6 +98,27 @@ and if you need to have access to the actual exception info you may use:
|
||||
the actual exception raised. The main attributes of interest are
|
||||
``.type``, ``.value`` and ``.traceback``.
|
||||
|
||||
Note that ``pytest.raises`` will match the exception type or any subclasses (like the standard ``except`` statement).
|
||||
If you want to check if a block of code is raising an exact exception type, you need to check that explicitly:
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_foo_not_implemented():
|
||||
def foo():
|
||||
raise NotImplementedError
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
foo()
|
||||
assert excinfo.type is RuntimeError
|
||||
|
||||
The :func:`pytest.raises` call will succeed, even though the function raises :class:`NotImplementedError`, because
|
||||
:class:`NotImplementedError` is a subclass of :class:`RuntimeError`; however the following `assert` statement will
|
||||
catch the problem.
|
||||
|
||||
Matching exception messages
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can pass a ``match`` keyword parameter to the context-manager to test
|
||||
that a regular expression matches on the string representation of an exception
|
||||
(similar to the ``TestCase.assertRaisesRegex`` method from ``unittest``):
|
||||
@@ -116,36 +136,113 @@ that a regular expression matches on the string representation of an exception
|
||||
with pytest.raises(ValueError, match=r".* 123 .*"):
|
||||
myfunc()
|
||||
|
||||
The regexp parameter of the ``match`` method is matched with the ``re.search``
|
||||
function, so in the above example ``match='123'`` would have worked as
|
||||
well.
|
||||
Notes:
|
||||
|
||||
There's an alternate form of the :func:`pytest.raises` function where you pass
|
||||
a function that will be executed with the given ``*args`` and ``**kwargs`` and
|
||||
assert that the given exception is raised:
|
||||
* The ``match`` parameter is matched with the :func:`re.search`
|
||||
function, so in the above example ``match='123'`` would have worked as well.
|
||||
* The ``match`` parameter also matches against `PEP-678 <https://peps.python.org/pep-0678/>`__ ``__notes__``.
|
||||
|
||||
|
||||
.. _`assert-matching-exception-groups`:
|
||||
|
||||
Matching exception groups
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can also use the :func:`excinfo.group_contains() <pytest.ExceptionInfo.group_contains>`
|
||||
method to test for exceptions returned as part of an :class:`ExceptionGroup`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
pytest.raises(ExpectedException, func, *args, **kwargs)
|
||||
def test_exception_in_group():
|
||||
with pytest.raises(ExceptionGroup) as excinfo:
|
||||
raise ExceptionGroup(
|
||||
"Group message",
|
||||
[
|
||||
RuntimeError("Exception 123 raised"),
|
||||
],
|
||||
)
|
||||
assert excinfo.group_contains(RuntimeError, match=r".* 123 .*")
|
||||
assert not excinfo.group_contains(TypeError)
|
||||
|
||||
The optional ``match`` keyword parameter works the same way as for
|
||||
:func:`pytest.raises`.
|
||||
|
||||
By default ``group_contains()`` will recursively search for a matching
|
||||
exception at any level of nested ``ExceptionGroup`` instances. You can
|
||||
specify a ``depth`` keyword parameter if you only want to match an
|
||||
exception at a specific level; exceptions contained directly in the top
|
||||
``ExceptionGroup`` would match ``depth=1``.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def test_exception_in_group_at_given_depth():
|
||||
with pytest.raises(ExceptionGroup) as excinfo:
|
||||
raise ExceptionGroup(
|
||||
"Group message",
|
||||
[
|
||||
RuntimeError(),
|
||||
ExceptionGroup(
|
||||
"Nested group",
|
||||
[
|
||||
TypeError(),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
assert excinfo.group_contains(RuntimeError, depth=1)
|
||||
assert excinfo.group_contains(TypeError, depth=2)
|
||||
assert not excinfo.group_contains(RuntimeError, depth=2)
|
||||
assert not excinfo.group_contains(TypeError, depth=1)
|
||||
|
||||
Alternate form (legacy)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
There is an alternate form where you pass
|
||||
a function that will be executed, along ``*args`` and ``**kwargs``, and :func:`pytest.raises`
|
||||
will execute the function with the arguments and assert that the given exception is raised:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def func(x):
|
||||
if x <= 0:
|
||||
raise ValueError("x needs to be larger than zero")
|
||||
|
||||
|
||||
pytest.raises(ValueError, func, x=-1)
|
||||
|
||||
The reporter will provide you with helpful output in case of failures such as *no
|
||||
exception* or *wrong exception*.
|
||||
|
||||
Note that it is also possible to specify a "raises" argument to
|
||||
``pytest.mark.xfail``, which checks that the test is failing in a more
|
||||
This form was the original :func:`pytest.raises` API, developed before the ``with`` statement was
|
||||
added to the Python language. Nowadays, this form is rarely used, with the context-manager form (using ``with``)
|
||||
being considered more readable.
|
||||
Nonetheless, this form is fully supported and not deprecated in any way.
|
||||
|
||||
xfail mark and pytest.raises
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
It is also possible to specify a ``raises`` argument to
|
||||
:ref:`pytest.mark.xfail <pytest.mark.xfail ref>`, which checks that the test is failing in a more
|
||||
specific way than just having any exception raised:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def f():
|
||||
raise IndexError()
|
||||
|
||||
|
||||
@pytest.mark.xfail(raises=IndexError)
|
||||
def test_f():
|
||||
f()
|
||||
|
||||
Using :func:`pytest.raises` is likely to be better for cases where you are
|
||||
testing exceptions your own code is deliberately raising, whereas using
|
||||
``@pytest.mark.xfail`` with a check function is probably better for something
|
||||
like documenting unfixed bugs (where the test describes what "should" happen)
|
||||
or bugs in dependencies.
|
||||
|
||||
This will only "xfail" if the test fails by raising ``IndexError`` or subclasses.
|
||||
|
||||
* Using :ref:`pytest.mark.xfail <pytest.mark.xfail ref>` with the ``raises`` parameter is probably better for something
|
||||
like documenting unfixed bugs (where the test describes what "should" happen) or bugs in dependencies.
|
||||
|
||||
* Using :func:`pytest.raises` is likely to be better for cases where you are
|
||||
testing exceptions your own code is deliberately raising, which is the majority of cases.
|
||||
|
||||
|
||||
.. _`assertwarns`:
|
||||
@@ -183,7 +280,7 @@ if you run this module:
|
||||
|
||||
$ pytest test_assert2.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -197,6 +294,7 @@ if you run this module:
|
||||
set2 = set("8035")
|
||||
> assert set1 == set2
|
||||
E AssertionError: assert {'0', '1', '3', '8'} == {'0', '3', '5', '8'}
|
||||
E
|
||||
E Extra items in the left set:
|
||||
E '1'
|
||||
E Extra items in the right set:
|
||||
|
||||
@@ -86,7 +86,7 @@ If you then run it with ``--lf``:
|
||||
|
||||
$ pytest --lf
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
run-last-failure: rerun previous 2 failures
|
||||
@@ -132,7 +132,7 @@ of ``FF`` and dots):
|
||||
|
||||
$ pytest --ff
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 50 items
|
||||
run-last-failure: rerun previous 2 failures first
|
||||
@@ -176,14 +176,21 @@ with more recent files coming first.
|
||||
Behavior when no tests failed in the last run
|
||||
---------------------------------------------
|
||||
|
||||
When no tests failed in the last run, or when no cached ``lastfailed`` data was
|
||||
found, ``pytest`` can be configured either to run all of the tests or no tests,
|
||||
using the ``--last-failed-no-failures`` option, which takes one of the following values:
|
||||
The ``--lfnf/--last-failed-no-failures`` option governs the behavior of ``--last-failed``.
|
||||
Determines whether to execute tests when there are no previously (known)
|
||||
failures or when no cached ``lastfailed`` data was found.
|
||||
|
||||
There are two options:
|
||||
|
||||
* ``all``: when there are no known test failures, runs all tests (the full test suite). This is the default.
|
||||
* ``none``: when there are no known test failures, just emits a message stating this and exit successfully.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest --last-failed --last-failed-no-failures all # run all tests (default behavior)
|
||||
pytest --last-failed --last-failed-no-failures none # run no tests and exit
|
||||
pytest --last-failed --last-failed-no-failures all # runs the full test suite (default behavior)
|
||||
pytest --last-failed --last-failed-no-failures none # runs no tests and exits successfully
|
||||
|
||||
The new config.cache object
|
||||
--------------------------------
|
||||
@@ -206,12 +213,12 @@ across pytest invocations:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mydata(request):
|
||||
val = request.config.cache.get("example/value", None)
|
||||
def mydata(pytestconfig):
|
||||
val = pytestconfig.cache.get("example/value", None)
|
||||
if val is None:
|
||||
expensive_computation()
|
||||
val = 42
|
||||
request.config.cache.set("example/value", val)
|
||||
pytestconfig.cache.set("example/value", val)
|
||||
return val
|
||||
|
||||
|
||||
@@ -274,7 +281,7 @@ You can always peek at the content of the cache using the
|
||||
|
||||
$ pytest --cache-show
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
cachedir: /home/sweet/project/.pytest_cache
|
||||
--------------------------- cache values for '*' ---------------------------
|
||||
@@ -296,7 +303,7 @@ filtering:
|
||||
|
||||
$ pytest --cache-show example/*
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
cachedir: /home/sweet/project/.pytest_cache
|
||||
----------------------- cache values for 'example/*' -----------------------
|
||||
|
||||
@@ -83,7 +83,7 @@ of the failing function and hide the other one:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Running pytest now produces this output:
|
||||
|
||||
$ pytest test_show_warnings.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -382,8 +382,6 @@ warnings: a WarningsRecorder instance. To view the recorded warnings, you can
|
||||
iterate over this instance, call ``len`` on it to get the number of recorded
|
||||
warnings, or index into it to get a particular recorded warning.
|
||||
|
||||
.. currentmodule:: _pytest.warnings
|
||||
|
||||
Full API: :class:`~_pytest.recwarn.WarningsRecorder`.
|
||||
|
||||
.. _`warns use cases`:
|
||||
|
||||
@@ -30,7 +30,7 @@ then you can just invoke ``pytest`` directly:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -58,7 +58,7 @@ and functions, including from test modules:
|
||||
|
||||
$ pytest --doctest-modules
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
@@ -224,6 +224,7 @@ place the objects you want to appear in the doctest namespace:
|
||||
.. code-block:: python
|
||||
|
||||
# content of conftest.py
|
||||
import pytest
|
||||
import numpy
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ How to use pytest with an existing test suite
|
||||
==============================================
|
||||
|
||||
Pytest can be used with most existing test suites, but its
|
||||
behavior differs from other test runners such as :ref:`nose <noseintegration>` or
|
||||
Python's default unittest framework.
|
||||
behavior differs from other test runners such as Python's
|
||||
default unittest framework.
|
||||
|
||||
Before using this section you will want to :ref:`install pytest <getstarted>`.
|
||||
|
||||
|
||||
@@ -135,10 +135,6 @@ Warning about unraisable exceptions and unhandled thread exceptions
|
||||
|
||||
.. versionadded:: 6.2
|
||||
|
||||
.. note::
|
||||
|
||||
These features only work on Python>=3.8.
|
||||
|
||||
Unhandled exceptions are exceptions that are raised in a situation in which
|
||||
they cannot propagate to a caller. The most common case is an exception raised
|
||||
in a :meth:`__del__ <object.__del__>` implementation.
|
||||
|
||||
@@ -433,7 +433,7 @@ marked ``smtp_connection`` fixture function. Running the test looks like this:
|
||||
|
||||
$ pytest test_module.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
@@ -494,7 +494,7 @@ Fixtures are created when first requested by a test, and are destroyed based on
|
||||
* ``function``: the default scope, the fixture is destroyed at the end of the test.
|
||||
* ``class``: the fixture is destroyed during teardown of the last test in the class.
|
||||
* ``module``: the fixture is destroyed during teardown of the last test in the module.
|
||||
* ``package``: the fixture is destroyed during teardown of the last test in the package.
|
||||
* ``package``: the fixture is destroyed during teardown of the last test in the package where the fixture is defined, including sub-packages and sub-directories within it.
|
||||
* ``session``: the fixture is destroyed at the end of the test session.
|
||||
|
||||
.. note::
|
||||
@@ -771,7 +771,7 @@ For yield fixtures, the first teardown code to run is from the right-most fixtur
|
||||
|
||||
$ pytest -s test_finalizers.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -805,7 +805,7 @@ For finalizers, the first fixture to run is last call to `request.addfinalizer`.
|
||||
|
||||
$ pytest -s test_finalizers.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -1271,7 +1271,7 @@ configured in multiple ways.
|
||||
Extending the previous example, we can flag the fixture to create two
|
||||
``smtp_connection`` fixture instances which will cause all tests using the fixture
|
||||
to run twice. The fixture function gets access to each parameter
|
||||
through the special :py:class:`request <FixtureRequest>` object:
|
||||
through the special :py:class:`request <pytest.FixtureRequest>` object:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -1414,27 +1414,28 @@ Running the above tests results in the following test IDs being used:
|
||||
|
||||
$ pytest --collect-only
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 12 items
|
||||
|
||||
<Module test_anothersmtp.py>
|
||||
<Function test_showhelo[smtp.gmail.com]>
|
||||
<Function test_showhelo[mail.python.org]>
|
||||
<Module test_emaillib.py>
|
||||
<Function test_email_received>
|
||||
<Module test_finalizers.py>
|
||||
<Function test_bar>
|
||||
<Module test_ids.py>
|
||||
<Function test_a[spam]>
|
||||
<Function test_a[ham]>
|
||||
<Function test_b[eggs]>
|
||||
<Function test_b[1]>
|
||||
<Module test_module.py>
|
||||
<Function test_ehlo[smtp.gmail.com]>
|
||||
<Function test_noop[smtp.gmail.com]>
|
||||
<Function test_ehlo[mail.python.org]>
|
||||
<Function test_noop[mail.python.org]>
|
||||
<Dir fixtures.rst-217>
|
||||
<Module test_anothersmtp.py>
|
||||
<Function test_showhelo[smtp.gmail.com]>
|
||||
<Function test_showhelo[mail.python.org]>
|
||||
<Module test_emaillib.py>
|
||||
<Function test_email_received>
|
||||
<Module test_finalizers.py>
|
||||
<Function test_bar>
|
||||
<Module test_ids.py>
|
||||
<Function test_a[spam]>
|
||||
<Function test_a[ham]>
|
||||
<Function test_b[eggs]>
|
||||
<Function test_b[1]>
|
||||
<Module test_module.py>
|
||||
<Function test_ehlo[smtp.gmail.com]>
|
||||
<Function test_noop[smtp.gmail.com]>
|
||||
<Function test_ehlo[mail.python.org]>
|
||||
<Function test_noop[mail.python.org]>
|
||||
|
||||
======================= 12 tests collected in 0.12s ========================
|
||||
|
||||
@@ -1468,7 +1469,7 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``:
|
||||
|
||||
$ pytest test_fixture_marks.py -v
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 3 items
|
||||
@@ -1518,7 +1519,7 @@ Here we declare an ``app`` fixture which receives the previously defined
|
||||
|
||||
$ pytest -v test_appsetup.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 2 items
|
||||
@@ -1598,7 +1599,7 @@ Let's run the tests in verbose mode and with looking at the print-output:
|
||||
|
||||
$ pytest -v -s test_module.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collecting ... collected 8 items
|
||||
@@ -1698,7 +1699,7 @@ and declare its use in a test module via a ``usefixtures`` marker:
|
||||
class TestDirectoryInit:
|
||||
def test_cwd_starts_empty(self):
|
||||
assert os.listdir(os.getcwd()) == []
|
||||
with open("myfile", "w") as f:
|
||||
with open("myfile", "w", encoding="utf-8") as f:
|
||||
f.write("hello")
|
||||
|
||||
def test_cwd_again_starts_empty(self):
|
||||
@@ -1720,8 +1721,7 @@ You can specify multiple fixtures like this:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.usefixtures("cleandir", "anotherfixture")
|
||||
def test():
|
||||
...
|
||||
def test(): ...
|
||||
|
||||
and you may specify fixture usage at the test module level using :globalvar:`pytestmark`:
|
||||
|
||||
@@ -1749,11 +1749,9 @@ into an ini-file:
|
||||
|
||||
@pytest.mark.usefixtures("my_other_fixture")
|
||||
@pytest.fixture
|
||||
def my_fixture_that_sadly_wont_use_my_other_fixture():
|
||||
...
|
||||
def my_fixture_that_sadly_wont_use_my_other_fixture(): ...
|
||||
|
||||
Currently this will not generate any error or warning, but this is intended
|
||||
to be handled by :issue:`3664`.
|
||||
This generates a deprecation warning, and will become an error in Pytest 8.
|
||||
|
||||
.. _`override fixtures`:
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ pytest and other test systems
|
||||
|
||||
existingtestsuite
|
||||
unittest
|
||||
nose
|
||||
xunit_setup
|
||||
|
||||
pytest development environment
|
||||
|
||||
@@ -172,6 +172,13 @@ the records for the ``setup`` and ``call`` stages during teardown like so:
|
||||
|
||||
The full API is available at :class:`pytest.LogCaptureFixture`.
|
||||
|
||||
.. warning::
|
||||
|
||||
The ``caplog`` fixture adds a handler to the root logger to capture logs. If the root logger is
|
||||
modified during a test, for example with ``logging.config.dictConfig``, this handler may be
|
||||
removed and cause no logs to be captured. To avoid this, ensure that any root logger configuration
|
||||
only adds to the existing handlers.
|
||||
|
||||
|
||||
.. _live_logs:
|
||||
|
||||
@@ -199,8 +206,9 @@ option names are:
|
||||
* ``log_cli_date_format``
|
||||
|
||||
If you need to record the whole test suite logging calls to a file, you can pass
|
||||
``--log-file=/path/to/log/file``. This log file is opened in write mode which
|
||||
``--log-file=/path/to/log/file``. This log file is opened in write mode by default which
|
||||
means that it will be overwritten at each run tests session.
|
||||
If you'd like the file opened in append mode instead, then you can pass ``--log-file-mode=a``.
|
||||
Note that relative paths for the log-file location, whether passed on the CLI or declared in a
|
||||
config file, are always resolved relative to the current working directory.
|
||||
|
||||
@@ -216,12 +224,13 @@ All of the log file options can also be set in the configuration INI file. The
|
||||
option names are:
|
||||
|
||||
* ``log_file``
|
||||
* ``log_file_mode``
|
||||
* ``log_file_level``
|
||||
* ``log_file_format``
|
||||
* ``log_file_date_format``
|
||||
|
||||
You can call ``set_log_path()`` to customize the log_file path dynamically. This functionality
|
||||
is considered **experimental**.
|
||||
is considered **experimental**. Note that ``set_log_path()`` respects the ``log_file_mode`` option.
|
||||
|
||||
.. _log_colors:
|
||||
|
||||
@@ -234,7 +243,7 @@ through ``add_color_level()``. Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.hookimpl
|
||||
@pytest.hookimpl(trylast=True)
|
||||
def pytest_configure(config):
|
||||
logging_plugin = config.pluginmanager.get_plugin("logging-plugin")
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
.. _`noseintegration`:
|
||||
|
||||
How to run tests written for nose
|
||||
=======================================
|
||||
|
||||
``pytest`` has basic support for running tests written for nose_.
|
||||
|
||||
.. warning::
|
||||
This functionality has been deprecated and is likely to be removed in ``pytest 8.x``.
|
||||
|
||||
.. _nosestyle:
|
||||
|
||||
Usage
|
||||
-------------
|
||||
|
||||
After :ref:`installation` type:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
python setup.py develop # make sure tests can import our package
|
||||
pytest # instead of 'nosetests'
|
||||
|
||||
and you should be able to run your nose style tests and
|
||||
make use of pytest's capabilities.
|
||||
|
||||
Supported nose Idioms
|
||||
----------------------
|
||||
|
||||
* ``setup()`` and ``teardown()`` at module/class/method level: any function or method called ``setup`` will be called during the setup phase for each test, same for ``teardown``.
|
||||
* ``SkipTest`` exceptions and markers
|
||||
* setup/teardown decorators
|
||||
* ``__test__`` attribute on modules/classes/functions
|
||||
* general usage of nose utilities
|
||||
|
||||
Unsupported idioms / known issues
|
||||
----------------------------------
|
||||
|
||||
- unittest-style ``setUp, tearDown, setUpClass, tearDownClass``
|
||||
are recognized only on ``unittest.TestCase`` classes but not
|
||||
on plain classes. ``nose`` supports these methods also on plain
|
||||
classes but pytest deliberately does not. As nose and pytest already
|
||||
both support ``setup_class, teardown_class, setup_method, teardown_method``
|
||||
it doesn't seem useful to duplicate the unittest-API like nose does.
|
||||
If you however rather think pytest should support the unittest-spelling on
|
||||
plain classes please post to :issue:`377`.
|
||||
|
||||
- nose imports test modules with the same import path (e.g.
|
||||
``tests.test_mode``) but different file system paths
|
||||
(e.g. ``tests/test_mode.py`` and ``other/tests/test_mode.py``)
|
||||
by extending sys.path/import semantics. pytest does not do that
|
||||
but there is discussion in :issue:`268` for adding some support. Note that
|
||||
`nose2 choose to avoid this sys.path/import hackery <https://nose2.readthedocs.io/en/latest/differences.html#test-discovery-and-loading>`_.
|
||||
|
||||
If you place a conftest.py file in the root directory of your project
|
||||
(as determined by pytest) pytest will run tests "nose style" against
|
||||
the code below that directory by adding it to your ``sys.path`` instead of
|
||||
running against your installed code.
|
||||
|
||||
You may find yourself wanting to do this if you ran ``python setup.py install``
|
||||
to set up your project, as opposed to ``python setup.py develop`` or any of
|
||||
the package manager equivalents. Installing with develop in a
|
||||
virtual environment like tox is recommended over this pattern.
|
||||
|
||||
- nose-style doctests are not collected and executed correctly,
|
||||
also doctest fixtures don't work.
|
||||
|
||||
- no nose-configuration is recognized.
|
||||
|
||||
- ``yield``-based methods are unsupported as of pytest 4.1.0. They are
|
||||
fundamentally incompatible with pytest because they don't support fixtures
|
||||
properly since collection and test execution are separated.
|
||||
|
||||
Migrating from nose to pytest
|
||||
------------------------------
|
||||
|
||||
`nose2pytest <https://github.com/pytest-dev/nose2pytest>`_ is a Python script
|
||||
and pytest plugin to help convert Nose-based tests into pytest-based tests.
|
||||
Specifically, the script transforms nose.tools.assert_* function calls into
|
||||
raw assert statements, while preserving format of original arguments
|
||||
as much as possible.
|
||||
|
||||
.. _nose: https://nose.readthedocs.io/en/latest/
|
||||
@@ -16,6 +16,12 @@ Examples for modifying traceback printing:
|
||||
pytest -l # show local variables (shortcut)
|
||||
pytest --no-showlocals # hide local variables (if addopts enables them)
|
||||
|
||||
pytest --capture=fd # default, capture at the file descriptor level
|
||||
pytest --capture=sys # capture at the sys level
|
||||
pytest --capture=no # don't capture
|
||||
pytest -s # don't capture (shortcut)
|
||||
pytest --capture=tee-sys # capture to logs but also output to sys level streams
|
||||
|
||||
pytest --tb=auto # (default) 'long' tracebacks for the first and last
|
||||
# entry, but 'short' style for the other entries
|
||||
pytest --tb=long # exhaustive, informative traceback formatting
|
||||
@@ -36,6 +42,16 @@ option you make sure a trace is shown.
|
||||
Verbosity
|
||||
--------------------------------------------------
|
||||
|
||||
Examples for modifying printing verbosity:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest --quiet # quiet - less verbose - mode
|
||||
pytest -q # quiet - less verbose - mode (shortcut)
|
||||
pytest -v # increase verbosity, display individual test names
|
||||
pytest -vv # more verbose, display more details from the test output
|
||||
pytest -vvv # not a standard , but may be used for even more detail in certain setups
|
||||
|
||||
The ``-v`` flag controls the verbosity of pytest output in various aspects: test session progress, assertion
|
||||
details when tests fail, fixtures details with ``--fixtures``, etc.
|
||||
|
||||
@@ -84,6 +100,7 @@ Executing pytest normally gives us this output (we are skipping the header to fo
|
||||
fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
|
||||
> assert fruits1 == fruits2
|
||||
E AssertionError: assert ['banana', 'a...elon', 'kiwi'] == ['banana', 'a...elon', 'kiwi']
|
||||
E
|
||||
E At index 2 diff: 'grapes' != 'orange'
|
||||
E Use -v to get more diff
|
||||
|
||||
@@ -95,6 +112,7 @@ Executing pytest normally gives us this output (we are skipping the header to fo
|
||||
number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
|
||||
> assert number_to_text1 == number_to_text2
|
||||
E AssertionError: assert {'0': 0, '1':..., '3': 3, ...} == {'0': 0, '10'...'30': 30, ...}
|
||||
E
|
||||
E Omitting 1 identical items, use -vv to show
|
||||
E Left contains 4 more items:
|
||||
E {'1': 1, '2': 2, '3': 3, '4': 4}
|
||||
@@ -146,12 +164,15 @@ Now we can increase pytest's verbosity:
|
||||
fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
|
||||
> assert fruits1 == fruits2
|
||||
E AssertionError: assert ['banana', 'a...elon', 'kiwi'] == ['banana', 'a...elon', 'kiwi']
|
||||
E
|
||||
E At index 2 diff: 'grapes' != 'orange'
|
||||
E
|
||||
E Full diff:
|
||||
E - ['banana', 'apple', 'orange', 'melon', 'kiwi']
|
||||
E ? ^ ^^
|
||||
E + ['banana', 'apple', 'grapes', 'melon', 'kiwi']
|
||||
E ? ^ ^ +
|
||||
E [
|
||||
E 'banana',
|
||||
E 'apple',...
|
||||
E
|
||||
E ...Full output truncated (7 lines hidden), use '-vv' to show
|
||||
|
||||
test_verbosity_example.py:8: AssertionError
|
||||
____________________________ test_numbers_fail _____________________________
|
||||
@@ -161,15 +182,15 @@ Now we can increase pytest's verbosity:
|
||||
number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
|
||||
> assert number_to_text1 == number_to_text2
|
||||
E AssertionError: assert {'0': 0, '1':..., '3': 3, ...} == {'0': 0, '10'...'30': 30, ...}
|
||||
E
|
||||
E Omitting 1 identical items, use -vv to show
|
||||
E Left contains 4 more items:
|
||||
E {'1': 1, '2': 2, '3': 3, '4': 4}
|
||||
E Right contains 4 more items:
|
||||
E {'10': 10, '20': 20, '30': 30, '40': 40}
|
||||
E Full diff:
|
||||
E - {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
|
||||
E ? - - - - - - - -
|
||||
E + {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4}
|
||||
E ...
|
||||
E
|
||||
E ...Full output truncated (16 lines hidden), use '-vv' to show
|
||||
|
||||
test_verbosity_example.py:14: AssertionError
|
||||
___________________________ test_long_text_fail ____________________________
|
||||
@@ -215,12 +236,20 @@ Now if we increase verbosity even more:
|
||||
fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
|
||||
> assert fruits1 == fruits2
|
||||
E AssertionError: assert ['banana', 'apple', 'grapes', 'melon', 'kiwi'] == ['banana', 'apple', 'orange', 'melon', 'kiwi']
|
||||
E
|
||||
E At index 2 diff: 'grapes' != 'orange'
|
||||
E
|
||||
E Full diff:
|
||||
E - ['banana', 'apple', 'orange', 'melon', 'kiwi']
|
||||
E ? ^ ^^
|
||||
E + ['banana', 'apple', 'grapes', 'melon', 'kiwi']
|
||||
E ? ^ ^ +
|
||||
E [
|
||||
E 'banana',
|
||||
E 'apple',
|
||||
E - 'orange',
|
||||
E ? ^ ^^
|
||||
E + 'grapes',
|
||||
E ? ^ ^ +
|
||||
E 'melon',
|
||||
E 'kiwi',
|
||||
E ]
|
||||
|
||||
test_verbosity_example.py:8: AssertionError
|
||||
____________________________ test_numbers_fail _____________________________
|
||||
@@ -230,16 +259,30 @@ Now if we increase verbosity even more:
|
||||
number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
|
||||
> assert number_to_text1 == number_to_text2
|
||||
E AssertionError: assert {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4} == {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
|
||||
E
|
||||
E Common items:
|
||||
E {'0': 0}
|
||||
E Left contains 4 more items:
|
||||
E {'1': 1, '2': 2, '3': 3, '4': 4}
|
||||
E Right contains 4 more items:
|
||||
E {'10': 10, '20': 20, '30': 30, '40': 40}
|
||||
E
|
||||
E Full diff:
|
||||
E - {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
|
||||
E ? - - - - - - - -
|
||||
E + {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4}
|
||||
E {
|
||||
E '0': 0,
|
||||
E - '10': 10,
|
||||
E ? - -
|
||||
E + '1': 1,
|
||||
E - '20': 20,
|
||||
E ? - -
|
||||
E + '2': 2,
|
||||
E - '30': 30,
|
||||
E ? - -
|
||||
E + '3': 3,
|
||||
E - '40': 40,
|
||||
E ? - -
|
||||
E + '4': 4,
|
||||
E }
|
||||
|
||||
test_verbosity_example.py:14: AssertionError
|
||||
___________________________ test_long_text_fail ____________________________
|
||||
@@ -251,9 +294,47 @@ Now if we increase verbosity even more:
|
||||
|
||||
test_verbosity_example.py:19: AssertionError
|
||||
========================= short test summary info ==========================
|
||||
FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
|
||||
FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
|
||||
FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
|
||||
FAILED test_verbosity_example.py::test_words_fail - AssertionError: assert ['banana', 'apple', 'grapes', 'melon', 'kiwi'] == ['banana', 'apple', 'orange', 'melon', 'kiwi']
|
||||
|
||||
At index 2 diff: 'grapes' != 'orange'
|
||||
|
||||
Full diff:
|
||||
[
|
||||
'banana',
|
||||
'apple',
|
||||
- 'orange',
|
||||
? ^ ^^
|
||||
+ 'grapes',
|
||||
? ^ ^ +
|
||||
'melon',
|
||||
'kiwi',
|
||||
]
|
||||
FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: assert {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4} == {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
|
||||
|
||||
Common items:
|
||||
{'0': 0}
|
||||
Left contains 4 more items:
|
||||
{'1': 1, '2': 2, '3': 3, '4': 4}
|
||||
Right contains 4 more items:
|
||||
{'10': 10, '20': 20, '30': 30, '40': 40}
|
||||
|
||||
Full diff:
|
||||
{
|
||||
'0': 0,
|
||||
- '10': 10,
|
||||
? - -
|
||||
+ '1': 1,
|
||||
- '20': 20,
|
||||
? - -
|
||||
+ '2': 2,
|
||||
- '30': 30,
|
||||
? - -
|
||||
+ '3': 3,
|
||||
- '40': 40,
|
||||
? - -
|
||||
+ '4': 4,
|
||||
}
|
||||
FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
|
||||
======================= 3 failed, 1 passed in 0.12s ========================
|
||||
|
||||
Notice now that:
|
||||
@@ -270,6 +351,22 @@ situations, for example you are shown even fixtures that start with ``_`` if you
|
||||
Using higher verbosity levels (``-vvv``, ``-vvvv``, ...) is supported, but has no effect in pytest itself at the moment,
|
||||
however some plugins might make use of higher verbosity.
|
||||
|
||||
.. _`pytest.fine_grained_verbosity`:
|
||||
|
||||
Fine-grained verbosity
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In addition to specifying the application wide verbosity level, it is possible to control specific aspects independently.
|
||||
This is done by setting a verbosity level in the configuration file for the specific aspect of the output.
|
||||
|
||||
:confval:`verbosity_assertions`: Controls how verbose the assertion output should be when pytest is executed. Running
|
||||
``pytest --no-header`` with a value of ``2`` would have the same output as the previous example, but each test inside
|
||||
the file is shown by a single character in the output.
|
||||
|
||||
:confval:`verbosity_test_cases`: Controls how verbose the test execution output should be when pytest is executed.
|
||||
Running ``pytest --no-header`` with a value of ``2`` would have the same output as the first verbosity example, but each
|
||||
test inside the file gets its own line in the output.
|
||||
|
||||
.. _`pytest.detailed_failed_tests_usage`:
|
||||
|
||||
Producing a detailed summary report
|
||||
@@ -324,7 +421,7 @@ Example:
|
||||
|
||||
$ pytest -ra
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 6 items
|
||||
|
||||
@@ -347,10 +444,19 @@ Example:
|
||||
E assert 0
|
||||
|
||||
test_example.py:14: AssertionError
|
||||
================================ XFAILURES =================================
|
||||
________________________________ test_xfail ________________________________
|
||||
|
||||
def test_xfail():
|
||||
> pytest.xfail("xfailing this test")
|
||||
E _pytest.outcomes.XFailed: xfailing this test
|
||||
|
||||
test_example.py:26: XFailed
|
||||
================================= XPASSES ==================================
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [1] test_example.py:22: skipping this test
|
||||
XFAIL test_example.py::test_xfail - reason: xfailing this test
|
||||
XPASS test_example.py::test_xpass always xfail
|
||||
XPASS test_example.py::test_xpass - always xfail
|
||||
ERROR test_example.py::test_error - assert 0
|
||||
FAILED test_example.py::test_fail - assert 0
|
||||
== 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
|
||||
@@ -380,7 +486,7 @@ More than one character can be used, so for example to only see failed and skipp
|
||||
|
||||
$ pytest -rfs
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 6 items
|
||||
|
||||
@@ -415,7 +521,7 @@ captured output:
|
||||
|
||||
$ pytest -rpP
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 6 items
|
||||
|
||||
@@ -478,7 +584,7 @@ integration servers, use this invocation:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest --junitxml=path
|
||||
pytest --junit-xml=path
|
||||
|
||||
to create an XML file at ``path``.
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ them in turn:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 3 items
|
||||
|
||||
@@ -167,7 +167,7 @@ Let's run this:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 3 items
|
||||
|
||||
|
||||
@@ -47,8 +47,7 @@ which may be passed an optional ``reason``:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.skip(reason="no way of currently testing this")
|
||||
def test_the_unknown():
|
||||
...
|
||||
def test_the_unknown(): ...
|
||||
|
||||
|
||||
Alternatively, it is also possible to skip imperatively during test execution or setup
|
||||
@@ -93,8 +92,7 @@ when run on an interpreter earlier than Python3.10:
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
If the condition evaluates to ``True`` during collection, the test function will be skipped,
|
||||
with the specified reason appearing in the summary when using ``-rs``.
|
||||
@@ -112,8 +110,7 @@ You can share ``skipif`` markers between modules. Consider this test module:
|
||||
|
||||
|
||||
@minversion
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
You can import the marker and reuse it in another test module:
|
||||
|
||||
@@ -124,8 +121,7 @@ You can import the marker and reuse it in another test module:
|
||||
|
||||
|
||||
@minversion
|
||||
def test_anotherfunction():
|
||||
...
|
||||
def test_anotherfunction(): ...
|
||||
|
||||
For larger test suites it's usually a good idea to have one file
|
||||
where you define the markers which you then consistently apply
|
||||
@@ -232,8 +228,7 @@ expect a test to fail:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
This test will run but no traceback will be reported when it fails. Instead, terminal
|
||||
reporting will list it in the "expected to fail" (``XFAIL``) or "unexpectedly
|
||||
@@ -275,8 +270,7 @@ that condition as the first parameter:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.xfail(sys.platform == "win32", reason="bug in a 3rd party library")
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
Note that you have to pass a reason as well (see the parameter description at
|
||||
:ref:`pytest.mark.xfail ref`).
|
||||
@@ -289,8 +283,7 @@ You can specify the motive of an expected failure with the ``reason`` parameter:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.xfail(reason="known parser issue")
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
|
||||
``raises`` parameter
|
||||
@@ -302,8 +295,7 @@ a single exception, or a tuple of exceptions, in the ``raises`` argument.
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.xfail(raises=RuntimeError)
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
Then the test will be reported as a regular failure if it fails with an
|
||||
exception not mentioned in ``raises``.
|
||||
@@ -317,8 +309,7 @@ even executed, use the ``run`` parameter as ``False``:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.xfail(run=False)
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
This is specially useful for xfailing tests that are crashing the interpreter and should be
|
||||
investigated later.
|
||||
@@ -334,8 +325,7 @@ You can change this by setting the ``strict`` keyword-only parameter to ``True``
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
|
||||
This will make ``XPASS`` ("unexpectedly passing") results from this test to fail the test suite.
|
||||
|
||||
@@ -8,9 +8,8 @@ How to use temporary directories and files in tests
|
||||
The ``tmp_path`` fixture
|
||||
------------------------
|
||||
|
||||
You can use the ``tmp_path`` fixture which will
|
||||
provide a temporary directory unique to the test invocation,
|
||||
created in the `base temporary directory`_.
|
||||
You can use the ``tmp_path`` fixture which will provide a temporary directory
|
||||
unique to each test function.
|
||||
|
||||
``tmp_path`` is a :class:`pathlib.Path` object. Here is an example test usage:
|
||||
|
||||
@@ -24,8 +23,8 @@ created in the `base temporary directory`_.
|
||||
d = tmp_path / "sub"
|
||||
d.mkdir()
|
||||
p = d / "hello.txt"
|
||||
p.write_text(CONTENT)
|
||||
assert p.read_text() == CONTENT
|
||||
p.write_text(CONTENT, encoding="utf-8")
|
||||
assert p.read_text(encoding="utf-8") == CONTENT
|
||||
assert len(list(tmp_path.iterdir())) == 1
|
||||
assert 0
|
||||
|
||||
@@ -36,7 +35,7 @@ Running this would result in a passed test except for the last
|
||||
|
||||
$ pytest test_tmp_path.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -51,8 +50,8 @@ Running this would result in a passed test except for the last
|
||||
d = tmp_path / "sub"
|
||||
d.mkdir()
|
||||
p = d / "hello.txt"
|
||||
p.write_text(CONTENT)
|
||||
assert p.read_text() == CONTENT
|
||||
p.write_text(CONTENT, encoding="utf-8")
|
||||
assert p.read_text(encoding="utf-8") == CONTENT
|
||||
assert len(list(tmp_path.iterdir())) == 1
|
||||
> assert 0
|
||||
E assert 0
|
||||
@@ -62,6 +61,11 @@ Running this would result in a passed test except for the last
|
||||
FAILED test_tmp_path.py::test_create_file - assert 0
|
||||
============================ 1 failed in 0.12s =============================
|
||||
|
||||
By default, ``pytest`` retains the temporary directory for the last 3 ``pytest``
|
||||
invocations. Concurrent invocations of the same test function are supported by
|
||||
configuring the base temporary directory to be unique for each concurrent
|
||||
run. See `temporary directory location and retention`_ for details.
|
||||
|
||||
.. _`tmp_path_factory example`:
|
||||
|
||||
The ``tmp_path_factory`` fixture
|
||||
@@ -100,7 +104,7 @@ See :ref:`tmp_path_factory API <tmp_path_factory factory api>` for details.
|
||||
.. _tmpdir:
|
||||
|
||||
The ``tmpdir`` and ``tmpdir_factory`` fixtures
|
||||
---------------------------------------------------
|
||||
----------------------------------------------
|
||||
|
||||
The ``tmpdir`` and ``tmpdir_factory`` fixtures are similar to ``tmp_path``
|
||||
and ``tmp_path_factory``, but use/return legacy `py.path.local`_ objects
|
||||
@@ -124,10 +128,10 @@ See :fixture:`tmpdir <tmpdir>` :fixture:`tmpdir_factory <tmpdir_factory>`
|
||||
API for details.
|
||||
|
||||
|
||||
.. _`base temporary directory`:
|
||||
.. _`temporary directory location and retention`:
|
||||
|
||||
The default base temporary directory
|
||||
-----------------------------------------------
|
||||
Temporary directory location and retention
|
||||
------------------------------------------
|
||||
|
||||
Temporary directories are by default created as sub-directories of
|
||||
the system temporary directory. The base name will be ``pytest-NUM`` where
|
||||
@@ -152,7 +156,7 @@ You can override the default temporary directory setting like this:
|
||||
for that purpose only.
|
||||
|
||||
When distributing tests on the local machine using ``pytest-xdist``, care is taken to
|
||||
automatically configure a basetemp directory for the sub processes such that all temporary
|
||||
data lands below a single per-test run basetemp directory.
|
||||
automatically configure a `basetemp` directory for the sub processes such that all temporary
|
||||
data lands below a single per-test run temporary directory.
|
||||
|
||||
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
|
||||
|
||||
@@ -140,7 +140,7 @@ the ``self.db`` values in the traceback:
|
||||
|
||||
$ pytest test_unittest_db.py
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
@@ -207,10 +207,10 @@ creation of a per-test temporary directory:
|
||||
@pytest.fixture(autouse=True)
|
||||
def initdir(self, tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path) # change to pytest-provided temporary directory
|
||||
tmp_path.joinpath("samplefile.ini").write_text("# testdata")
|
||||
tmp_path.joinpath("samplefile.ini").write_text("# testdata", encoding="utf-8")
|
||||
|
||||
def test_method(self):
|
||||
with open("samplefile.ini") as f:
|
||||
with open("samplefile.ini", encoding="utf-8") as f:
|
||||
s = f.read()
|
||||
assert "testdata" in s
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ in the current directory and its subdirectories. More generally, pytest follows
|
||||
Specifying which tests to run
|
||||
------------------------------
|
||||
|
||||
Pytest supports several ways to run and select tests from the command-line.
|
||||
Pytest supports several ways to run and select tests from the command-line or from a file
|
||||
(see below for :ref:`reading arguments from file <args-from-file>`).
|
||||
|
||||
**Run tests in a module**
|
||||
|
||||
@@ -44,23 +45,34 @@ Use ``""`` instead of ``''`` in expression when running this on Windows
|
||||
|
||||
.. _nodeids:
|
||||
|
||||
**Run tests by node ids**
|
||||
**Run tests by collection arguments**
|
||||
|
||||
Each collected test is assigned a unique ``nodeid`` which consist of the module filename followed
|
||||
by specifiers like class names, function names and parameters from parametrization, separated by ``::`` characters.
|
||||
Pass the module filename relative to the working directory, followed by specifiers like the class name and function name
|
||||
separated by ``::`` characters, and parameters from parameterization enclosed in ``[]``.
|
||||
|
||||
To run a specific test within a module:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest test_mod.py::test_func
|
||||
pytest tests/test_mod.py::test_func
|
||||
|
||||
|
||||
Another example specifying a test method in the command line:
|
||||
To run all tests in a class:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest test_mod.py::TestClass::test_method
|
||||
pytest tests/test_mod.py::TestClass
|
||||
|
||||
Specifying a specific test method:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest tests/test_mod.py::TestClass::test_method
|
||||
|
||||
Specifying a specific parametrization of a test:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest tests/test_mod.py::test_func[x1,y2]
|
||||
|
||||
**Run tests by marker expressions**
|
||||
|
||||
@@ -80,6 +92,28 @@ For more information see :ref:`marks <mark>`.
|
||||
|
||||
This will import ``pkg.testing`` and use its filesystem location to find and run tests from.
|
||||
|
||||
.. _args-from-file:
|
||||
|
||||
**Read arguments from file**
|
||||
|
||||
.. versionadded:: 8.2
|
||||
|
||||
All of the above can be read from a file using the ``@`` prefix:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pytest @tests_to_run.txt
|
||||
|
||||
where ``tests_to_run.txt`` contains an entry per line, e.g.:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
tests/test_file.py
|
||||
tests/test_mod.py::test_func[x1,y2]
|
||||
tests/test_mod.py::TestClass
|
||||
-m slow
|
||||
|
||||
This file can also be generated using ``pytest --collect-only -q`` and modified as needed.
|
||||
|
||||
Getting help on version, option names, environment variables
|
||||
--------------------------------------------------------------
|
||||
@@ -173,7 +207,8 @@ You can invoke ``pytest`` from Python code directly:
|
||||
|
||||
this acts as if you would call "pytest" from the command line.
|
||||
It will not raise :class:`SystemExit` but return the :ref:`exit code <exit-codes>` instead.
|
||||
You can pass in options and arguments:
|
||||
If you don't pass it any arguments, ``main`` reads the arguments from the command line arguments of the process (:data:`sys.argv`), which may be undesirable.
|
||||
You can pass in options and arguments explicitly:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
||||
@@ -56,23 +56,17 @@ The remaining hook functions will not be called in this case.
|
||||
|
||||
.. _`hookwrapper`:
|
||||
|
||||
hookwrapper: executing around other hooks
|
||||
hook wrappers: executing around other hooks
|
||||
-------------------------------------------------
|
||||
|
||||
.. currentmodule:: _pytest.core
|
||||
|
||||
|
||||
|
||||
pytest plugins can implement hook wrappers which wrap the execution
|
||||
of other hook implementations. A hook wrapper is a generator function
|
||||
which yields exactly once. When pytest invokes hooks it first executes
|
||||
hook wrappers and passes the same arguments as to the regular hooks.
|
||||
|
||||
At the yield point of the hook wrapper pytest will execute the next hook
|
||||
implementations and return their result to the yield point in the form of
|
||||
a :py:class:`Result <pluggy._Result>` instance which encapsulates a result or
|
||||
exception info. The yield point itself will thus typically not raise
|
||||
exceptions (unless there are bugs).
|
||||
implementations and return their result to the yield point, or will
|
||||
propagate an exception if they raised.
|
||||
|
||||
Here is an example definition of a hook wrapper:
|
||||
|
||||
@@ -81,26 +75,35 @@ Here is an example definition of a hook wrapper:
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
@pytest.hookimpl(wrapper=True)
|
||||
def pytest_pyfunc_call(pyfuncitem):
|
||||
do_something_before_next_hook_executes()
|
||||
|
||||
outcome = yield
|
||||
# outcome.excinfo may be None or a (cls, val, tb) tuple
|
||||
# If the outcome is an exception, will raise the exception.
|
||||
res = yield
|
||||
|
||||
res = outcome.get_result() # will raise if outcome was exception
|
||||
new_res = post_process_result(res)
|
||||
|
||||
post_process_result(res)
|
||||
# Override the return value to the plugin system.
|
||||
return new_res
|
||||
|
||||
outcome.force_result(new_res) # to override the return value to the plugin system
|
||||
The hook wrapper needs to return a result for the hook, or raise an exception.
|
||||
|
||||
Note that hook wrappers don't return results themselves, they merely
|
||||
perform tracing or other side effects around the actual hook implementations.
|
||||
If the result of the underlying hook is a mutable object, they may modify
|
||||
that result but it's probably better to avoid it.
|
||||
In many cases, the wrapper only needs to perform tracing or other side effects
|
||||
around the actual hook implementations, in which case it can return the result
|
||||
value of the ``yield``. The simplest (though useless) hook wrapper is
|
||||
``return (yield)``.
|
||||
|
||||
In other cases, the wrapper wants the adjust or adapt the result, in which case
|
||||
it can return a new value. If the result of the underlying hook is a mutable
|
||||
object, the wrapper may modify that result, but it's probably better to avoid it.
|
||||
|
||||
If the hook implementation failed with an exception, the wrapper can handle that
|
||||
exception using a ``try-catch-finally`` around the ``yield``, by propagating it,
|
||||
suppressing it, or raising a different exception entirely.
|
||||
|
||||
For more information, consult the
|
||||
:ref:`pluggy documentation about hookwrappers <pluggy:hookwrappers>`.
|
||||
:ref:`pluggy documentation about hook wrappers <pluggy:hookwrappers>`.
|
||||
|
||||
.. _plugin-hookorder:
|
||||
|
||||
@@ -130,11 +133,14 @@ after others, i.e. the position in the ``N``-sized list of functions:
|
||||
|
||||
|
||||
# Plugin 3
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
@pytest.hookimpl(wrapper=True)
|
||||
def pytest_collection_modifyitems(items):
|
||||
# will execute even before the tryfirst one above!
|
||||
outcome = yield
|
||||
# will execute after all non-hookwrappers executed
|
||||
try:
|
||||
return (yield)
|
||||
finally:
|
||||
# will execute after all non-wrappers executed
|
||||
...
|
||||
|
||||
Here is the order of execution:
|
||||
|
||||
@@ -149,13 +155,13 @@ Here is the order of execution:
|
||||
Plugin1).
|
||||
|
||||
4. Plugin3's pytest_collection_modifyitems then executing the code after the yield
|
||||
point. The yield receives a :py:class:`Result <pluggy._Result>` instance which encapsulates
|
||||
the result from calling the non-wrappers. Wrappers shall not modify the result.
|
||||
point. The yield receives the result from calling the non-wrappers, or raises
|
||||
an exception if the non-wrappers raised.
|
||||
|
||||
It's possible to use ``tryfirst`` and ``trylast`` also in conjunction with
|
||||
``hookwrapper=True`` in which case it will influence the ordering of hookwrappers
|
||||
among each other.
|
||||
It's possible to use ``tryfirst`` and ``trylast`` also on hook wrappers
|
||||
in which case it will influence the ordering of hook wrappers among each other.
|
||||
|
||||
.. _`declaringhooks`:
|
||||
|
||||
Declaring new hooks
|
||||
------------------------
|
||||
@@ -165,13 +171,11 @@ Declaring new hooks
|
||||
This is a quick overview on how to add new hooks and how they work in general, but a more complete
|
||||
overview can be found in `the pluggy documentation <https://pluggy.readthedocs.io/en/latest/>`__.
|
||||
|
||||
.. currentmodule:: _pytest.hookspec
|
||||
|
||||
Plugins and ``conftest.py`` files may declare new hooks that can then be
|
||||
implemented by other plugins in order to alter behaviour or interact with
|
||||
the new plugin:
|
||||
|
||||
.. autofunction:: pytest_addhooks
|
||||
.. autofunction:: _pytest.hookspec.pytest_addhooks
|
||||
:noindex:
|
||||
|
||||
Hooks are usually declared as do-nothing functions that contain only
|
||||
|
||||
@@ -46,24 +46,18 @@ Plugin discovery order at tool startup
|
||||
|
||||
5. by loading all plugins specified through the :envvar:`PYTEST_PLUGINS` environment variable.
|
||||
|
||||
6. by loading all :file:`conftest.py` files as inferred by the command line
|
||||
invocation:
|
||||
6. by loading all "initial ":file:`conftest.py` files:
|
||||
|
||||
- if no test paths are specified, use the current dir as a test path
|
||||
- if exists, load ``conftest.py`` and ``test*/conftest.py`` relative
|
||||
to the directory part of the first test path. After the ``conftest.py``
|
||||
file is loaded, load all plugins specified in its
|
||||
:globalvar:`pytest_plugins` variable if present.
|
||||
|
||||
Note that pytest does not find ``conftest.py`` files in deeper nested
|
||||
sub directories at tool startup. It is usually a good idea to keep
|
||||
your ``conftest.py`` file in the top level test or project root directory.
|
||||
|
||||
7. by recursively loading all plugins specified by the
|
||||
:globalvar:`pytest_plugins` variable in ``conftest.py`` files.
|
||||
- determine the test paths: specified on the command line, otherwise in
|
||||
:confval:`testpaths` if defined and running from the rootdir, otherwise the
|
||||
current dir
|
||||
- for each test path, load ``conftest.py`` and ``test*/conftest.py`` relative
|
||||
to the directory part of the test path, if exist. Before a ``conftest.py``
|
||||
file is loaded, load ``conftest.py`` files in all of its parent directories.
|
||||
After a ``conftest.py`` file is loaded, recursively load all plugins specified
|
||||
in its :globalvar:`pytest_plugins` variable if present.
|
||||
|
||||
|
||||
.. _`pytest/plugin`: http://bitbucket.org/pytest-dev/pytest/src/tip/pytest/plugin/
|
||||
.. _`conftest.py plugins`:
|
||||
.. _`localplugin`:
|
||||
.. _`local conftest plugins`:
|
||||
@@ -108,9 +102,9 @@ Here is how you might run it::
|
||||
See also: :ref:`pythonpath`.
|
||||
|
||||
.. note::
|
||||
Some hooks should be implemented only in plugins or conftest.py files situated at the
|
||||
tests root directory due to how pytest discovers plugins during startup,
|
||||
see the documentation of each hook for details.
|
||||
Some hooks cannot be implemented in conftest.py files which are not
|
||||
:ref:`initial <pluginorder>` due to how pytest discovers plugins during
|
||||
startup. See the documentation of each hook for details.
|
||||
|
||||
Writing your own plugin
|
||||
-----------------------
|
||||
@@ -448,7 +442,7 @@ in our ``pytest.ini`` to tell pytest where to look for example files.
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
configfile: pytest.ini
|
||||
collected 2 items
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
:orphan:
|
||||
|
||||
.. sidebar:: Next Open Trainings
|
||||
.. sidebar:: Next Open Trainings and Events
|
||||
|
||||
- `pytest tips and tricks for a better testsuite <https://ep2023.europython.eu/session/pytest-tips-and-tricks-for-a-better-testsuite>`_, at `Europython 2023 <https://ep2023.europython.eu/>`_, July 18th (3h), Prague/Remote
|
||||
- `Professional Testing with Python <https://python-academy.com/courses/python_course_testing.html>`_, via `Python Academy <https://www.python-academy.com/>`_, March 5th to 7th 2024 (3 day in-depth training), Leipzig/Remote
|
||||
- `Professional Testing with Python <https://python-academy.com/courses/python_course_testing.html>`_, via `Python Academy <https://www.python-academy.com/>`_ (3 day in-depth training):
|
||||
* **June 11th to 13th 2024**, Remote
|
||||
* **March 4th to 6th 2025**, Leipzig, Germany / Remote
|
||||
- `pytest development sprint <https://github.com/pytest-dev/pytest/discussions/11655>`_, **June 17th -- 22nd 2024**
|
||||
- pytest tips and tricks for a better testsuite, `Europython 2024 <https://ep2024.europython.eu/>`_, **July 8th -- 14th 2024** (3h), Prague
|
||||
|
||||
Also see :doc:`previous talks and blogposts <talks>`.
|
||||
|
||||
@@ -18,7 +21,7 @@ The ``pytest`` framework makes it easy to write small, readable tests, and can
|
||||
scale to support complex functional testing for applications and libraries.
|
||||
|
||||
|
||||
``pytest`` requires: Python 3.7+ or PyPy3.
|
||||
``pytest`` requires: Python 3.8+ or PyPy3.
|
||||
|
||||
**PyPI package name**: :pypi:`pytest`
|
||||
|
||||
@@ -43,7 +46,7 @@ To execute it:
|
||||
|
||||
$ pytest
|
||||
=========================== test session starts ============================
|
||||
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
|
||||
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
||||
rootdir: /home/sweet/project
|
||||
collected 1 item
|
||||
|
||||
@@ -75,17 +78,17 @@ Features
|
||||
|
||||
- :ref:`Modular fixtures <fixture>` for managing small or parametrized long-lived test resources
|
||||
|
||||
- Can run :ref:`unittest <unittest>` (including trial) and :ref:`nose <noseintegration>` test suites out of the box
|
||||
- Can run :ref:`unittest <unittest>` (including trial) test suites out of the box
|
||||
|
||||
- Python 3.7+ or PyPy 3
|
||||
- Python 3.8+ or PyPy 3
|
||||
|
||||
- Rich plugin architecture, with over 800+ :ref:`external plugins <plugin-list>` and thriving community
|
||||
- Rich plugin architecture, with over 1300+ :ref:`external plugins <plugin-list>` and thriving community
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
* :ref:`Get started <get-started>` - install pytest and grasp its basics just twenty minutes
|
||||
* :ref:`Get started <get-started>` - install pytest and grasp its basics in just twenty minutes
|
||||
* :ref:`How-to guides <how-to>` - step-by-step guides, covering a vast range of use-cases and needs
|
||||
* :ref:`Reference guides <reference>` - includes the complete pytest API reference, lists of plugins and more
|
||||
* :ref:`Explanation <explanation>` - background, discussion of key topics, answers to higher-level questions
|
||||
|
||||
@@ -90,7 +90,7 @@ and can also be used to hold pytest configuration if they have a ``[pytest]`` se
|
||||
setup.cfg
|
||||
~~~~~~~~~
|
||||
|
||||
``setup.cfg`` files are general purpose configuration files, used originally by :doc:`distutils <python:distutils/configfile>`, and can also be used to hold pytest configuration
|
||||
``setup.cfg`` files are general purpose configuration files, used originally by ``distutils`` (now deprecated) and `setuptools <https://setuptools.pypa.io/en/latest/userguide/declarative_config.html>`__, and can also be used to hold pytest configuration
|
||||
if they have a ``[tool:pytest]`` section.
|
||||
|
||||
.. code-block:: ini
|
||||
@@ -177,13 +177,20 @@ Files will only be matched for configuration if:
|
||||
* ``tox.ini``: contains a ``[pytest]`` section.
|
||||
* ``setup.cfg``: contains a ``[tool:pytest]`` section.
|
||||
|
||||
Finally, a ``pyproject.toml`` file will be considered the ``configfile`` if no other match was found, in this case
|
||||
even if it does not contain a ``[tool.pytest.ini_options]`` table (this was added in ``8.1``).
|
||||
|
||||
The files are considered in the order above. Options from multiple ``configfiles`` candidates
|
||||
are never merged - the first match wins.
|
||||
|
||||
The configuration file also determines the value of the ``rootpath``.
|
||||
|
||||
The :class:`Config <pytest.Config>` object (accessible via hooks or through the :fixture:`pytestconfig` fixture)
|
||||
will subsequently carry these attributes:
|
||||
|
||||
- :attr:`config.rootpath <pytest.Config.rootpath>`: the determined root directory, guaranteed to exist.
|
||||
- :attr:`config.rootpath <pytest.Config.rootpath>`: the determined root directory, guaranteed to exist. It is used as
|
||||
a reference directory for constructing test addresses ("nodeids") and can be used also by plugins for storing
|
||||
per-testrun information.
|
||||
|
||||
- :attr:`config.inipath <pytest.Config.inipath>`: the determined ``configfile``, may be ``None``
|
||||
(it is named ``inipath`` for historical reasons).
|
||||
@@ -193,9 +200,7 @@ will subsequently carry these attributes:
|
||||
versions of the older ``config.rootdir`` and ``config.inifile``, which have type
|
||||
``py.path.local``, and still exist for backward compatibility.
|
||||
|
||||
The ``rootdir`` is used as a reference directory for constructing test
|
||||
addresses ("nodeids") and can be used also by plugins for storing
|
||||
per-testrun information.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -11,9 +11,6 @@ Fixtures reference
|
||||
.. seealso:: :ref:`about-fixtures`
|
||||
.. seealso:: :ref:`how-to-fixtures`
|
||||
|
||||
|
||||
.. currentmodule:: _pytest.python
|
||||
|
||||
.. _`Dependency injection`: https://en.wikipedia.org/wiki/Dependency_injection
|
||||
|
||||
|
||||
@@ -76,15 +73,13 @@ Built-in fixtures
|
||||
:class:`pathlib.Path` objects.
|
||||
|
||||
:fixture:`tmpdir`
|
||||
Provide a :class:`py.path.local` object to a temporary
|
||||
Provide a `py.path.local <https://py.readthedocs.io/en/latest/path.html>`_ object to a temporary
|
||||
directory which is unique to each test function;
|
||||
replaced by :fixture:`tmp_path`.
|
||||
|
||||
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
|
||||
|
||||
:fixture:`tmpdir_factory`
|
||||
Make session-scoped temporary directories and return
|
||||
:class:`py.path.local` objects;
|
||||
``py.path.local`` objects;
|
||||
replaced by :fixture:`tmp_path_factory`.
|
||||
|
||||
|
||||
@@ -98,7 +93,7 @@ Fixture availability is determined from the perspective of the test. A fixture
|
||||
is only available for tests to request if they are in the scope that fixture is
|
||||
defined in. If a fixture is defined inside a class, it can only be requested by
|
||||
tests inside that class. But if a fixture is defined inside the global scope of
|
||||
the module, than every test in that module, even if it's defined inside a class,
|
||||
the module, then every test in that module, even if it's defined inside a class,
|
||||
can request it.
|
||||
|
||||
Similarly, a test can also only be affected by an autouse fixture if that test
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
:tocdepth: 3
|
||||
|
||||
.. _`api-reference`:
|
||||
|
||||
API Reference
|
||||
@@ -77,11 +79,13 @@ pytest.xfail
|
||||
pytest.exit
|
||||
~~~~~~~~~~~
|
||||
|
||||
.. autofunction:: pytest.exit(reason, [returncode=False, msg=None])
|
||||
.. autofunction:: pytest.exit(reason, [returncode=None, msg=None])
|
||||
|
||||
pytest.main
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Tutorial**: :ref:`pytest.main-usage`
|
||||
|
||||
.. autofunction:: pytest.main
|
||||
|
||||
pytest.param
|
||||
@@ -132,7 +136,7 @@ pytest.freeze_includes
|
||||
Marks
|
||||
-----
|
||||
|
||||
Marks can be used apply meta data to *test functions* (but not fixtures), which can then be accessed by
|
||||
Marks can be used to apply metadata to *test functions* (but not fixtures), which can then be accessed by
|
||||
fixtures or plugins.
|
||||
|
||||
|
||||
@@ -160,8 +164,7 @@ Add warning filters to marked test items.
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.filterwarnings("ignore:.*usage will be deprecated.*:DeprecationWarning")
|
||||
def test_foo():
|
||||
...
|
||||
def test_foo(): ...
|
||||
|
||||
|
||||
.. _`pytest.mark.parametrize ref`:
|
||||
@@ -235,22 +238,23 @@ pytest.mark.xfail
|
||||
|
||||
Marks a test function as *expected to fail*.
|
||||
|
||||
.. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=False)
|
||||
.. py:function:: pytest.mark.xfail(condition=False, *, reason=None, raises=None, run=True, strict=xfail_strict)
|
||||
|
||||
:type condition: bool or str
|
||||
:param condition:
|
||||
:keyword Union[bool, str] condition:
|
||||
Condition for marking the test function as xfail (``True/False`` or a
|
||||
:ref:`condition string <string conditions>`). If a bool, you also have
|
||||
:ref:`condition string <string conditions>`). If a ``bool``, you also have
|
||||
to specify ``reason`` (see :ref:`condition string <string conditions>`).
|
||||
:keyword str reason:
|
||||
Reason why the test function is marked as xfail.
|
||||
:keyword Type[Exception] raises:
|
||||
Exception subclass (or tuple of subclasses) expected to be raised by the test function; other exceptions will fail the test.
|
||||
Exception class (or tuple of classes) expected to be raised by the test function; other exceptions will fail the test.
|
||||
Note that subclasses of the classes passed will also result in a match (similar to how the ``except`` statement works).
|
||||
|
||||
:keyword bool run:
|
||||
If the test function should actually be executed. If ``False``, the function will always xfail and will
|
||||
Whether the test function should actually be executed. If ``False``, the function will always xfail and will
|
||||
not be executed (useful if a function is segfaulting).
|
||||
:keyword bool strict:
|
||||
* If ``False`` (the default) the function will be shown in the terminal output as ``xfailed`` if it fails
|
||||
* If ``False`` the function will be shown in the terminal output as ``xfailed`` if it fails
|
||||
and as ``xpass`` if it passes. In both cases this will not cause the test suite to fail as a whole. This
|
||||
is particularly useful to mark *flaky* tests (tests that fail at random) to be tackled later.
|
||||
* If ``True``, the function will be shown in the terminal output as ``xfailed`` if it fails, but if it
|
||||
@@ -258,6 +262,8 @@ Marks a test function as *expected to fail*.
|
||||
that are always failing and there should be a clear indication if they unexpectedly start to pass (for example
|
||||
a new release of a library fixes a known bug).
|
||||
|
||||
Defaults to :confval:`xfail_strict`, which is ``False`` by default.
|
||||
|
||||
|
||||
Custom marks
|
||||
~~~~~~~~~~~~
|
||||
@@ -269,8 +275,7 @@ For example:
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.timeout(10, "slow", method="thread")
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
Will create and attach a :class:`Mark <pytest.Mark>` object to the collected
|
||||
:class:`Item <pytest.Item>`, which can then be accessed by fixtures or hooks with
|
||||
@@ -287,8 +292,7 @@ Example for using multiple custom markers:
|
||||
|
||||
@pytest.mark.timeout(10, "slow", method="thread")
|
||||
@pytest.mark.slow
|
||||
def test_function():
|
||||
...
|
||||
def test_function(): ...
|
||||
|
||||
When :meth:`Node.iter_markers <_pytest.nodes.Node.iter_markers>` or :meth:`Node.iter_markers_with_node <_pytest.nodes.Node.iter_markers_with_node>` is used with multiple markers, the marker closest to the function will be iterated over first. The above example will result in ``@pytest.mark.slow`` followed by ``@pytest.mark.timeout(...)``.
|
||||
|
||||
@@ -605,10 +609,30 @@ Hooks
|
||||
|
||||
**Tutorial**: :ref:`writing-plugins`
|
||||
|
||||
.. currentmodule:: _pytest.hookspec
|
||||
|
||||
Reference to all hooks which can be implemented by :ref:`conftest.py files <localplugin>` and :ref:`plugins <plugins>`.
|
||||
|
||||
@pytest.hookimpl
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
.. function:: pytest.hookimpl
|
||||
:decorator:
|
||||
|
||||
pytest's decorator for marking functions as hook implementations.
|
||||
|
||||
See :ref:`writinghooks` and :func:`pluggy.HookimplMarker`.
|
||||
|
||||
@pytest.hookspec
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
.. function:: pytest.hookspec
|
||||
:decorator:
|
||||
|
||||
pytest's decorator for marking functions as hook specifications.
|
||||
|
||||
See :ref:`declaringhooks` and :func:`pluggy.HookspecMarker`.
|
||||
|
||||
.. currentmodule:: _pytest.hookspec
|
||||
|
||||
Bootstrapping hooks
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -616,8 +640,6 @@ Bootstrapping hooks called for plugins registered early enough (internal and set
|
||||
|
||||
.. hook:: pytest_load_initial_conftests
|
||||
.. autofunction:: pytest_load_initial_conftests
|
||||
.. hook:: pytest_cmdline_preparse
|
||||
.. autofunction:: pytest_cmdline_preparse
|
||||
.. hook:: pytest_cmdline_parse
|
||||
.. autofunction:: pytest_cmdline_parse
|
||||
.. hook:: pytest_cmdline_main
|
||||
@@ -655,6 +677,8 @@ Collection hooks
|
||||
.. autofunction:: pytest_collection
|
||||
.. hook:: pytest_ignore_collect
|
||||
.. autofunction:: pytest_ignore_collect
|
||||
.. hook:: pytest_collect_directory
|
||||
.. autofunction:: pytest_collect_directory
|
||||
.. hook:: pytest_collect_file
|
||||
.. autofunction:: pytest_collect_file
|
||||
.. hook:: pytest_pycollect_makemodule
|
||||
@@ -783,23 +807,16 @@ reporting or interaction with exceptions:
|
||||
.. autofunction:: pytest_leave_pdb
|
||||
|
||||
|
||||
Objects
|
||||
-------
|
||||
Collection tree objects
|
||||
-----------------------
|
||||
|
||||
Full reference to objects accessible from :ref:`fixtures <fixture>` or :ref:`hooks <hook-reference>`.
|
||||
These are the collector and item classes (collectively called "nodes") which
|
||||
make up the collection tree.
|
||||
|
||||
Node
|
||||
~~~~
|
||||
|
||||
CallInfo
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.CallInfo()
|
||||
:members:
|
||||
|
||||
|
||||
Class
|
||||
~~~~~
|
||||
|
||||
.. autoclass:: pytest.Class()
|
||||
.. autoclass:: _pytest.nodes.Node()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -810,32 +827,12 @@ Collector
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
CollectReport
|
||||
~~~~~~~~~~~~~
|
||||
Item
|
||||
~~~~
|
||||
|
||||
.. autoclass:: pytest.CollectReport()
|
||||
.. autoclass:: pytest.Item()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:inherited-members:
|
||||
|
||||
Config
|
||||
~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Config()
|
||||
:members:
|
||||
|
||||
ExceptionInfo
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.ExceptionInfo()
|
||||
:members:
|
||||
|
||||
|
||||
ExitCode
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.ExitCode
|
||||
:members:
|
||||
|
||||
File
|
||||
~~~~
|
||||
@@ -844,14 +841,6 @@ File
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
FixtureDef
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: _pytest.fixtures.FixtureDef()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
FSCollector
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -859,6 +848,34 @@ FSCollector
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Session
|
||||
~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Session()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Package
|
||||
~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Package()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Module
|
||||
~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Module()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Class
|
||||
~~~~~
|
||||
|
||||
.. autoclass:: pytest.Class()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Function
|
||||
~~~~~~~~
|
||||
|
||||
@@ -873,10 +890,64 @@ FunctionDefinition
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Item
|
||||
~~~~
|
||||
|
||||
.. autoclass:: pytest.Item()
|
||||
Objects
|
||||
-------
|
||||
|
||||
Objects accessible from :ref:`fixtures <fixture>` or :ref:`hooks <hook-reference>`
|
||||
or importable from ``pytest``.
|
||||
|
||||
|
||||
CallInfo
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.CallInfo()
|
||||
:members:
|
||||
|
||||
CollectReport
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.CollectReport()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:inherited-members:
|
||||
|
||||
Config
|
||||
~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Config()
|
||||
:members:
|
||||
|
||||
Dir
|
||||
~~~
|
||||
|
||||
.. autoclass:: pytest.Dir()
|
||||
:members:
|
||||
|
||||
Directory
|
||||
~~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Directory()
|
||||
:members:
|
||||
|
||||
ExceptionInfo
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.ExceptionInfo()
|
||||
:members:
|
||||
|
||||
|
||||
ExitCode
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.ExitCode
|
||||
:members:
|
||||
|
||||
|
||||
FixtureDef
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.FixtureDef()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -907,19 +978,6 @@ Metafunc
|
||||
.. autoclass:: pytest.Metafunc()
|
||||
:members:
|
||||
|
||||
Module
|
||||
~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Module()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
Node
|
||||
~~~~
|
||||
|
||||
.. autoclass:: _pytest.nodes.Node()
|
||||
:members:
|
||||
|
||||
Parser
|
||||
~~~~~~
|
||||
|
||||
@@ -941,13 +999,6 @@ PytestPluginManager
|
||||
:inherited-members:
|
||||
:show-inheritance:
|
||||
|
||||
Session
|
||||
~~~~~~~
|
||||
|
||||
.. autoclass:: pytest.Session()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
TestReport
|
||||
~~~~~~~~~~
|
||||
|
||||
@@ -962,10 +1013,10 @@ TestShortLogReport
|
||||
.. autoclass:: pytest.TestShortLogReport()
|
||||
:members:
|
||||
|
||||
_Result
|
||||
Result
|
||||
~~~~~~~
|
||||
|
||||
Result object used within :ref:`hook wrappers <hookwrapper>`, see :py:class:`_Result in the pluggy documentation <pluggy._callers._Result>` for more information.
|
||||
Result object used within :ref:`hook wrappers <hookwrapper>`, see :py:class:`Result in the pluggy documentation <pluggy.Result>` for more information.
|
||||
|
||||
Stash
|
||||
~~~~~
|
||||
@@ -1066,6 +1117,11 @@ When set (regardless of value), pytest acknowledges that is running in a CI proc
|
||||
This contains a command-line (parsed by the py:mod:`shlex` module) that will be **prepended** to the command line given
|
||||
by the user, see :ref:`adding default options` for more information.
|
||||
|
||||
.. envvar:: PYTEST_VERSION
|
||||
|
||||
This environment variable is defined at the start of the pytest session and is undefined afterwards.
|
||||
It contains the value of ``pytest.__version__``, and among other things can be used to easily check if a code is running from within a pytest run.
|
||||
|
||||
.. envvar:: PYTEST_CURRENT_TEST
|
||||
|
||||
This is not meant to be set by users, but is set by pytest internally with the name of the current test so other
|
||||
@@ -1104,19 +1160,22 @@ When set to ``0``, pytest will not use color.
|
||||
|
||||
.. envvar:: NO_COLOR
|
||||
|
||||
When set (regardless of value), pytest will not use color in terminal output.
|
||||
When set to a non-empty string (regardless of value), pytest will not use color in terminal output.
|
||||
``PY_COLORS`` takes precedence over ``NO_COLOR``, which takes precedence over ``FORCE_COLOR``.
|
||||
See `no-color.org <https://no-color.org/>`__ for other libraries supporting this community standard.
|
||||
|
||||
.. envvar:: FORCE_COLOR
|
||||
|
||||
When set (regardless of value), pytest will use color in terminal output.
|
||||
When set to a non-empty string (regardless of value), pytest will use color in terminal output.
|
||||
``PY_COLORS`` and ``NO_COLOR`` take precedence over ``FORCE_COLOR``.
|
||||
|
||||
Exceptions
|
||||
----------
|
||||
|
||||
.. autoclass:: pytest.UsageError()
|
||||
.. autoexception:: pytest.UsageError()
|
||||
:show-inheritance:
|
||||
|
||||
.. autoexception:: pytest.FixtureLookupError()
|
||||
:show-inheritance:
|
||||
|
||||
.. _`warnings ref`:
|
||||
@@ -1150,7 +1209,7 @@ Custom warnings generated in some situations such as improper usage or deprecate
|
||||
.. autoclass:: pytest.PytestReturnNotNoneWarning
|
||||
:show-inheritance:
|
||||
|
||||
.. autoclass:: pytest.PytestRemovedIn8Warning
|
||||
.. autoclass:: pytest.PytestRemovedIn9Warning
|
||||
:show-inheritance:
|
||||
|
||||
.. autoclass:: pytest.PytestUnhandledCoroutineWarning
|
||||
@@ -1220,6 +1279,18 @@ passed multiple times. The expected format is ``name=value``. For example::
|
||||
variables, that will be expanded. For more information about cache plugin
|
||||
please refer to :ref:`cache_provider`.
|
||||
|
||||
.. confval:: consider_namespace_packages
|
||||
|
||||
Controls if pytest should attempt to identify `namespace packages <https://packaging.python.org/en/latest/guides/packaging-namespace-packages>`__
|
||||
when collecting Python modules. Default is ``False``.
|
||||
|
||||
Set to ``True`` if the package you are testing is part of a namespace package.
|
||||
|
||||
Only `native namespace packages <https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#native-namespace-packages>`__
|
||||
are supported, with no plans to support `legacy namespace packages <https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#legacy-namespace-packages>`__.
|
||||
|
||||
.. versionadded:: 8.1
|
||||
|
||||
.. confval:: console_output_style
|
||||
|
||||
Sets the console output style while running tests:
|
||||
@@ -1619,11 +1690,11 @@ passed multiple times. The expected format is ``name=value``. For example::
|
||||
Additionally, ``pytest`` will attempt to intelligently identify and ignore a
|
||||
virtualenv by the presence of an activation script. Any directory deemed to
|
||||
be the root of a virtual environment will not be considered during test
|
||||
collection unless ``‑‑collect‑in‑virtualenv`` is given. Note also that
|
||||
``norecursedirs`` takes precedence over ``‑‑collect‑in‑virtualenv``; e.g. if
|
||||
collection unless ``--collect-in-virtualenv`` is given. Note also that
|
||||
``norecursedirs`` takes precedence over ``--collect-in-virtualenv``; e.g. if
|
||||
you intend to run tests in a virtualenv with a base directory that matches
|
||||
``'.*'`` you *must* override ``norecursedirs`` in addition to using the
|
||||
``‑‑collect‑in‑virtualenv`` flag.
|
||||
``--collect-in-virtualenv`` flag.
|
||||
|
||||
|
||||
.. confval:: python_classes
|
||||
@@ -1798,6 +1869,32 @@ passed multiple times. The expected format is ``name=value``. For example::
|
||||
clean_db
|
||||
|
||||
|
||||
.. confval:: verbosity_assertions
|
||||
|
||||
Set a verbosity level specifically for assertion related output, overriding the application wide level.
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[pytest]
|
||||
verbosity_assertions = 2
|
||||
|
||||
Defaults to application wide verbosity level (via the ``-v`` command-line option). A special value of
|
||||
"auto" can be used to explicitly use the global verbosity level.
|
||||
|
||||
|
||||
.. confval:: verbosity_test_cases
|
||||
|
||||
Set a verbosity level specifically for test case execution related output, overriding the application wide level.
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[pytest]
|
||||
verbosity_test_cases = 2
|
||||
|
||||
Defaults to application wide verbosity level (via the ``-v`` command-line option). A special value of
|
||||
"auto" can be used to explicitly use the global verbosity level.
|
||||
|
||||
|
||||
.. confval:: xfail_strict
|
||||
|
||||
If set to ``True``, tests marked with ``@pytest.mark.xfail`` that actually succeed will by default fail the
|
||||
@@ -1871,8 +1968,12 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
tests. Optional argument: glob (default: '*').
|
||||
--cache-clear Remove all cache contents at start of test run
|
||||
--lfnf={all,none}, --last-failed-no-failures={all,none}
|
||||
Which tests to run with no previously (known)
|
||||
failures
|
||||
With ``--lf``, determines whether to execute tests
|
||||
when there are no previously (known) failures or
|
||||
when no cached ``lastfailed`` data was found.
|
||||
``all`` (the default) runs the full test suite
|
||||
again. ``none`` just emits a message about no known
|
||||
failures and exits successfully.
|
||||
--sw, --stepwise Exit on test failure and continue from last failing
|
||||
test next time
|
||||
--sw-skip, --stepwise-skip
|
||||
@@ -1957,7 +2058,7 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
failure
|
||||
--doctest-glob=pat Doctests file matching pattern, default: test*.txt
|
||||
--doctest-ignore-import-errors
|
||||
Ignore doctest ImportErrors
|
||||
Ignore doctest collection errors
|
||||
--doctest-continue-on-failure
|
||||
For a given doctest, continue to run after the first
|
||||
failure
|
||||
@@ -2006,6 +2107,8 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
--log-cli-date-format=LOG_CLI_DATE_FORMAT
|
||||
Log date format used by the logging module
|
||||
--log-file=LOG_FILE Path to a file when logging will be written to
|
||||
--log-file-mode={w,a}
|
||||
Log file open mode
|
||||
--log-file-level=LOG_FILE_LEVEL
|
||||
Log file logging level
|
||||
--log-file-format=LOG_FILE_FORMAT
|
||||
@@ -2021,7 +2124,7 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
|
||||
[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg|pyproject.toml file found:
|
||||
|
||||
markers (linelist): Markers for test functions
|
||||
markers (linelist): Register new markers for test functions
|
||||
empty_parameter_set_mark (string):
|
||||
Default marker for empty parametersets
|
||||
norecursedirs (args): Directory patterns to avoid for recursion
|
||||
@@ -2031,6 +2134,9 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
Each line specifies a pattern for
|
||||
warnings.filterwarnings. Processed after
|
||||
-W/--pythonwarnings.
|
||||
consider_namespace_packages (bool):
|
||||
Consider namespace packages when resolving module
|
||||
names during import
|
||||
usefixtures (args): List of default fixtures to be used with this
|
||||
project
|
||||
python_files (args): Glob-style file patterns for Python test module
|
||||
@@ -2049,6 +2155,11 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
progress information ("progress" (percentage) |
|
||||
"count" | "progress-even-when-capture-no" (forces
|
||||
progress even when capture=no)
|
||||
verbosity_test_cases (string):
|
||||
Specify a verbosity level for test case execution,
|
||||
overriding the main level. Higher levels will
|
||||
provide more detailed information about each test
|
||||
case executed.
|
||||
xfail_strict (bool): Default for the strict parameter of xfail markers
|
||||
when not given explicitly (default: False)
|
||||
tmp_path_retention_count (string):
|
||||
@@ -2062,6 +2173,10 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
enable_assertion_pass_hook (bool):
|
||||
Enables the pytest_assertion_pass hook. Make sure to
|
||||
delete any previously generated pyc cache files.
|
||||
verbosity_assertions (string):
|
||||
Specify a verbosity level for assertions, overriding
|
||||
the main level. Higher levels will provide more
|
||||
detailed explanation when an assertion fails.
|
||||
junit_suite_name (string):
|
||||
Test suite name for JUnit report
|
||||
junit_logging (string):
|
||||
@@ -2092,6 +2207,8 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||
log_cli_date_format (string):
|
||||
Default value for --log-cli-date-format
|
||||
log_file (string): Default value for --log-file
|
||||
log_file_mode (string):
|
||||
Default value for --log-file-mode
|
||||
log_file_level (string):
|
||||
Default value for --log-file-level
|
||||
log_file_format (string):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
pallets-sphinx-themes
|
||||
pluggy>=1.0
|
||||
pluggy>=1.5.0
|
||||
pygments-pytest>=2.3.0
|
||||
sphinx-removed-in>=0.2.0
|
||||
sphinx>=5,<6
|
||||
sphinx>=7
|
||||
sphinxcontrib-trio
|
||||
sphinxcontrib-svg2pdfconverter
|
||||
# Pin packaging because it no longer handles 'latest' version, which
|
||||
|
||||
@@ -3,6 +3,7 @@ from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
issues_url = "https://api.github.com/repos/pytest-dev/pytest/issues"
|
||||
|
||||
|
||||
|
||||
317
pyproject.toml
317
pyproject.toml
@@ -1,14 +1,291 @@
|
||||
[build-system]
|
||||
requires = [
|
||||
# sync with setup.py until we discard non-pep-517/518
|
||||
"setuptools>=45.0",
|
||||
"setuptools-scm[toml]>=6.2.3",
|
||||
[project]
|
||||
name = "pytest"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
readme = "README.rst"
|
||||
keywords = [
|
||||
"test",
|
||||
"unittest",
|
||||
]
|
||||
license = {text = "MIT"}
|
||||
authors = [
|
||||
{name = "Holger Krekel"},
|
||||
{name = "Bruno Oliveira"},
|
||||
{name = "Ronny Pfannschmidt"},
|
||||
{name = "Floris Bruynooghe"},
|
||||
{name = "Brianna Laugher"},
|
||||
{name = "Florian Bruhin"},
|
||||
{name = "Others (See AUTHORS)"},
|
||||
]
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Development Status :: 6 - Mature",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: MacOS",
|
||||
"Operating System :: Microsoft :: Windows",
|
||||
"Operating System :: POSIX",
|
||||
"Operating System :: Unix",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Topic :: Software Development :: Libraries",
|
||||
"Topic :: Software Development :: Testing",
|
||||
"Topic :: Utilities",
|
||||
]
|
||||
dynamic = [
|
||||
"version",
|
||||
]
|
||||
dependencies = [
|
||||
'colorama; sys_platform == "win32"',
|
||||
'exceptiongroup>=1.0.0rc8; python_version < "3.11"',
|
||||
"iniconfig",
|
||||
"packaging",
|
||||
"pluggy<2.0,>=1.5",
|
||||
'tomli>=1; python_version < "3.11"',
|
||||
]
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"argcomplete",
|
||||
"attrs>=19.2",
|
||||
"hypothesis>=3.56",
|
||||
"mock",
|
||||
"pygments>=2.7.2",
|
||||
"requests",
|
||||
"setuptools",
|
||||
"xmlschema",
|
||||
]
|
||||
[project.urls]
|
||||
Changelog = "https://docs.pytest.org/en/stable/changelog.html"
|
||||
Homepage = "https://docs.pytest.org/en/latest/"
|
||||
Source = "https://github.com/pytest-dev/pytest"
|
||||
Tracker = "https://github.com/pytest-dev/pytest/issues"
|
||||
Twitter = "https://twitter.com/pytestdotorg"
|
||||
[project.scripts]
|
||||
"py.test" = "pytest:console_main"
|
||||
pytest = "pytest:console_main"
|
||||
|
||||
[build-system]
|
||||
build-backend = "setuptools.build_meta"
|
||||
requires = [
|
||||
"setuptools>=61",
|
||||
"setuptools-scm[toml]>=6.2.3",
|
||||
]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"_pytest" = ["py.typed"]
|
||||
"pytest" = ["py.typed"]
|
||||
|
||||
[tool.setuptools_scm]
|
||||
write_to = "src/_pytest/_version.py"
|
||||
|
||||
[tool.black]
|
||||
target-version = ['py38']
|
||||
|
||||
[tool.ruff]
|
||||
src = ["src"]
|
||||
line-length = 88
|
||||
|
||||
[tool.ruff.format]
|
||||
docstring-code-format = true
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"B", # bugbear
|
||||
"D", # pydocstyle
|
||||
"E", # pycodestyle
|
||||
"F", # pyflakes
|
||||
"I", # isort
|
||||
"PYI", # flake8-pyi
|
||||
"UP", # pyupgrade
|
||||
"RUF", # ruff
|
||||
"W", # pycodestyle
|
||||
"PIE", # flake8-pie
|
||||
"PGH004", # pygrep-hooks - Use specific rule codes when using noqa
|
||||
"PLE", # pylint error
|
||||
"PLW", # pylint warning
|
||||
"PLR1714", # Consider merging multiple comparisons
|
||||
]
|
||||
ignore = [
|
||||
# bugbear ignore
|
||||
"B004", # Using `hasattr(x, "__call__")` to test if x is callable is unreliable.
|
||||
"B007", # Loop control variable `i` not used within loop body
|
||||
"B009", # Do not call `getattr` with a constant attribute value
|
||||
"B010", # [*] Do not call `setattr` with a constant attribute value.
|
||||
"B011", # Do not `assert False` (`python -O` removes these calls)
|
||||
"B028", # No explicit `stacklevel` keyword argument found
|
||||
# pycodestyle ignore
|
||||
# pytest can do weird low-level things, and we usually know
|
||||
# what we're doing when we use type(..) is ...
|
||||
"E721", # Do not compare types, use `isinstance()`
|
||||
# pydocstyle ignore
|
||||
"D100", # Missing docstring in public module
|
||||
"D101", # Missing docstring in public class
|
||||
"D102", # Missing docstring in public method
|
||||
"D103", # Missing docstring in public function
|
||||
"D104", # Missing docstring in public package
|
||||
"D105", # Missing docstring in magic method
|
||||
"D106", # Missing docstring in public nested class
|
||||
"D107", # Missing docstring in `__init__`
|
||||
"D209", # [*] Multi-line docstring closing quotes should be on a separate line
|
||||
"D205", # 1 blank line required between summary line and description
|
||||
"D400", # First line should end with a period
|
||||
"D401", # First line of docstring should be in imperative mood
|
||||
"D402", # First line should not be the function's signature
|
||||
"D404", # First word of the docstring should not be "This"
|
||||
"D415", # First line should end with a period, question mark, or exclamation point
|
||||
# ruff ignore
|
||||
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
|
||||
# pylint ignore
|
||||
"PLW0603", # Using the global statement
|
||||
"PLW0120", # remove the else and dedent its contents
|
||||
"PLW2901", # for loop variable overwritten by assignment target
|
||||
"PLR5501", # Use `elif` instead of `else` then `if`
|
||||
]
|
||||
|
||||
[tool.ruff.lint.pycodestyle]
|
||||
# In order to be able to format for 88 char in ruff format
|
||||
max-line-length = 120
|
||||
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
convention = "pep257"
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
force-single-line = true
|
||||
combine-as-imports = true
|
||||
force-sort-within-sections = true
|
||||
order-by-type = false
|
||||
known-local-folder = ["pytest", "_pytest"]
|
||||
lines-after-imports = 2
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"src/_pytest/_py/**/*.py" = ["B", "PYI"]
|
||||
"src/_pytest/_version.py" = ["I001"]
|
||||
"testing/python/approx.py" = ["B015"]
|
||||
|
||||
[tool.pylint.main]
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length = 120
|
||||
disable= [
|
||||
"abstract-method",
|
||||
"arguments-differ",
|
||||
"arguments-renamed",
|
||||
"assigning-non-slot",
|
||||
"attribute-defined-outside-init",
|
||||
"bad-classmethod-argument",
|
||||
"bad-mcs-method-argument",
|
||||
"broad-exception-caught",
|
||||
"broad-exception-raised",
|
||||
"cell-var-from-loop",
|
||||
"comparison-of-constants",
|
||||
"comparison-with-callable",
|
||||
"comparison-with-itself",
|
||||
"condition-evals-to-constant",
|
||||
"consider-using-dict-items",
|
||||
"consider-using-enumerate",
|
||||
"consider-using-from-import",
|
||||
"consider-using-f-string",
|
||||
"consider-using-in",
|
||||
"consider-using-sys-exit",
|
||||
"consider-using-ternary",
|
||||
"consider-using-with",
|
||||
"cyclic-import",
|
||||
"disallowed-name",
|
||||
"duplicate-code",
|
||||
"eval-used",
|
||||
"exec-used",
|
||||
"expression-not-assigned",
|
||||
"fixme",
|
||||
"global-statement",
|
||||
"implicit-str-concat",
|
||||
"import-error",
|
||||
"import-outside-toplevel",
|
||||
"inconsistent-return-statements",
|
||||
"invalid-bool-returned",
|
||||
"invalid-name",
|
||||
"invalid-repr-returned",
|
||||
"invalid-str-returned",
|
||||
"keyword-arg-before-vararg",
|
||||
"line-too-long",
|
||||
"method-hidden",
|
||||
"misplaced-bare-raise",
|
||||
"missing-docstring",
|
||||
"missing-timeout",
|
||||
"multiple-statements",
|
||||
"no-else-break",
|
||||
"no-else-continue",
|
||||
"no-else-raise",
|
||||
"no-else-return",
|
||||
"no-member",
|
||||
"no-name-in-module",
|
||||
"no-self-argument",
|
||||
"not-an-iterable",
|
||||
"not-callable",
|
||||
"pointless-exception-statement",
|
||||
"pointless-statement",
|
||||
"pointless-string-statement",
|
||||
"protected-access",
|
||||
"raise-missing-from",
|
||||
"redefined-argument-from-local",
|
||||
"redefined-builtin",
|
||||
"redefined-outer-name",
|
||||
"reimported",
|
||||
"simplifiable-condition",
|
||||
"simplifiable-if-expression",
|
||||
"singleton-comparison",
|
||||
"superfluous-parens",
|
||||
"super-init-not-called",
|
||||
"too-few-public-methods",
|
||||
"too-many-ancestors",
|
||||
"too-many-arguments",
|
||||
"too-many-branches",
|
||||
"too-many-function-args",
|
||||
"too-many-instance-attributes",
|
||||
"too-many-lines",
|
||||
"too-many-locals",
|
||||
"too-many-nested-blocks",
|
||||
"too-many-public-methods",
|
||||
"too-many-return-statements",
|
||||
"too-many-statements",
|
||||
"try-except-raise",
|
||||
"typevar-name-incorrect-variance",
|
||||
"unbalanced-tuple-unpacking",
|
||||
"undefined-loop-variable",
|
||||
"undefined-variable",
|
||||
"unexpected-keyword-arg",
|
||||
"unidiomatic-typecheck",
|
||||
"unnecessary-comprehension",
|
||||
"unnecessary-dunder-call",
|
||||
"unnecessary-lambda",
|
||||
"unnecessary-lambda-assignment",
|
||||
"unpacking-non-sequence",
|
||||
"unspecified-encoding",
|
||||
"unsubscriptable-object",
|
||||
"unused-argument",
|
||||
"unused-import",
|
||||
"unused-variable",
|
||||
"used-before-assignment",
|
||||
"use-dict-literal",
|
||||
"use-implicit-booleaness-not-comparison",
|
||||
"use-implicit-booleaness-not-len",
|
||||
"useless-else-on-loop",
|
||||
"useless-import-alias",
|
||||
"useless-return",
|
||||
"use-maxsplit-arg",
|
||||
"using-constant-test",
|
||||
"wrong-import-order",
|
||||
]
|
||||
|
||||
[tool.check-wheel-contents]
|
||||
# check-wheel-contents is executed by the build-and-inspect-python-package action.
|
||||
# W009: Wheel contains multiple toplevel library entries
|
||||
ignore = "W009"
|
||||
|
||||
[tool.pyproject-fmt]
|
||||
indent = 4
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
minversion = "2.0"
|
||||
addopts = "-rfEX -p pytester --strict-markers"
|
||||
@@ -17,7 +294,12 @@ python_classes = ["Test", "Acceptance"]
|
||||
python_functions = ["test"]
|
||||
# NOTE: "doc" is not included here, but gets tested explicitly via "doctesting".
|
||||
testpaths = ["testing"]
|
||||
norecursedirs = ["testing/example_scripts"]
|
||||
norecursedirs = [
|
||||
"testing/example_scripts",
|
||||
".*",
|
||||
"build",
|
||||
"dist",
|
||||
]
|
||||
xfail_strict = true
|
||||
filterwarnings = [
|
||||
"error",
|
||||
@@ -63,7 +345,6 @@ markers = [
|
||||
"uses_pexpect",
|
||||
]
|
||||
|
||||
|
||||
[tool.towncrier]
|
||||
package = "pytest"
|
||||
package_dir = "src"
|
||||
@@ -112,10 +393,18 @@ template = "changelog/_template.rst"
|
||||
name = "Trivial/Internal Changes"
|
||||
showcontent = true
|
||||
|
||||
[tool.black]
|
||||
target-version = ['py37']
|
||||
|
||||
# check-wheel-contents is executed by the build-and-inspect-python-package action.
|
||||
[tool.check-wheel-contents]
|
||||
# W009: Wheel contains multiple toplevel library entries
|
||||
ignore = "W009"
|
||||
[tool.mypy]
|
||||
files = ["src", "testing", "scripts"]
|
||||
mypy_path = ["src"]
|
||||
check_untyped_defs = true
|
||||
disallow_any_generics = true
|
||||
disallow_untyped_defs = true
|
||||
ignore_missing_imports = true
|
||||
show_error_codes = true
|
||||
strict_equality = true
|
||||
warn_redundant_casts = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
warn_unused_configs = true
|
||||
no_implicit_reexport = true
|
||||
warn_unused_ignores = true
|
||||
|
||||
1
scripts/.gitignore
vendored
Normal file
1
scripts/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
latest-release-notes.md
|
||||
67
scripts/generate-gh-release-notes.py
Normal file
67
scripts/generate-gh-release-notes.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# mypy: disallow-untyped-defs
|
||||
"""
|
||||
Script used to generate a Markdown file containing only the changelog entries of a specific pytest release, which
|
||||
is then published as a GitHub Release during deploy (see workflows/deploy.yml).
|
||||
|
||||
The script requires ``pandoc`` to be previously installed in the system -- we need to convert from RST (the format of
|
||||
our CHANGELOG) into Markdown (which is required by GitHub Releases).
|
||||
|
||||
Requires Python3.6+.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
from typing import Sequence
|
||||
|
||||
import pypandoc
|
||||
|
||||
|
||||
def extract_changelog_entries_for(version: str) -> str:
|
||||
p = Path(__file__).parent.parent / "doc/en/changelog.rst"
|
||||
changelog_lines = p.read_text(encoding="UTF-8").splitlines()
|
||||
|
||||
title_regex = re.compile(r"pytest (\d\.\d+\.\d+\w*) \(\d{4}-\d{2}-\d{2}\)")
|
||||
consuming_version = False
|
||||
version_lines = []
|
||||
for line in changelog_lines:
|
||||
m = title_regex.match(line)
|
||||
if m:
|
||||
# Found the version we want: start to consume lines until we find the next version title.
|
||||
if m.group(1) == version:
|
||||
consuming_version = True
|
||||
# Found a new version title while parsing the version we want: break out.
|
||||
elif consuming_version:
|
||||
break
|
||||
if consuming_version:
|
||||
version_lines.append(line)
|
||||
|
||||
return "\n".join(version_lines)
|
||||
|
||||
|
||||
def convert_rst_to_md(text: str) -> str:
|
||||
result = pypandoc.convert_text(
|
||||
text, "md", format="rst", extra_args=["--wrap=preserve"]
|
||||
)
|
||||
assert isinstance(result, str), repr(result)
|
||||
return result
|
||||
|
||||
|
||||
def main(argv: Sequence[str]) -> int:
|
||||
if len(argv) != 3:
|
||||
print("Usage: generate-gh-release-notes VERSION FILE")
|
||||
return 2
|
||||
|
||||
version, filename = argv[1:3]
|
||||
print(f"Generating GitHub release notes for version {version}")
|
||||
rst_body = extract_changelog_entries_for(version)
|
||||
md_body = convert_rst_to_md(rst_body)
|
||||
Path(filename).write_text(md_body, encoding="UTF-8")
|
||||
print()
|
||||
print(f"Done: {filename}")
|
||||
print()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user