1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
|
%global _empty_manifest_terminate_build 0
Name: python-flake8-pytest-style
Version: 1.7.2
Release: 1
Summary: A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
License: MIT
URL: https://pypi.org/project/flake8-pytest-style
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/c0/6b/12c40bbb136b0423485f5b4ac5939fb984ddbe85f38e6ed484472a89692d/flake8_pytest_style-1.7.2.tar.gz
BuildArch: noarch
Requires: python3-flake8-plugin-utils
%description
# flake8-pytest-style
[](https://pypi.org/project/flake8-pytest-style)
[](https://pypi.org/project/flake8-pytest-style)
[](https://pypistats.org/packages/flake8-pytest-style)
[](https://github.com/m-burst/flake8-pytest-style/actions/workflows/ci.yml)
[](https://codecov.io/gh/m-burst/flake8-pytest-style)
[](https://en.wikipedia.org/wiki/MIT_License)
[](https://github.com/ambv/black)
## Description
A `flake8` plugin checking common style issues or inconsistencies with `pytest`-based tests.
Currently the following errors are reported:
| Code | Description |
| ------- | ----------- |
| [PT001] | use @pytest.fixture() over @pytest.fixture <br> (configurable by `pytest-fixture-no-parentheses`) |
| [PT002] | configuration for fixture '{name}' specified via positional args, use kwargs |
| [PT003] | scope='function' is implied in @pytest.fixture() |
| [PT004] | fixture '{name}' does not return anything, add leading underscore |
| [PT005] | fixture '{name}' returns a value, remove leading underscore |
| [PT006] | wrong name(s) type in @pytest.mark.parametrize, expected {expected_type} <br> (configurable by `pytest-parametrize-names-type`) |
| [PT007] | wrong values type in @pytest.mark.parametrize, expected {expected_type} <br> (configurable by `pytest-parametrize-values-type` and `pytest-parametrize-values-row-type`) |
| [PT008] | use return_value= instead of patching with lambda |
| [PT009] | use a regular assert instead of unittest-style '{assertion}' |
| [PT010] | set the expected exception in pytest.raises() |
| [PT011] | pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception <br> (configurable by `pytest-raises-require-match-for`) |
| [PT012] | pytest.raises() block should contain a single simple statement |
| [PT013] | found incorrect import of pytest, use simple 'import pytest' instead |
| [PT014] | found duplicate test cases {indexes} in @pytest.mark.parametrize |
| [PT015] | assertion always fails, replace with pytest.fail() |
| [PT016] | no message passed to pytest.fail() |
| [PT017] | found assertion on exception {name} in except block, use pytest.raises() instead |
| [PT018] | assertion should be broken down into multiple parts |
| [PT019] | fixture {name} without value is injected as parameter, use @pytest.mark.usefixtures instead |
| [PT020] | @pytest.yield_fixture is deprecated, use @pytest.fixture |
| [PT021] | use yield instead of request.addfinalizer |
| [PT022] | no teardown in fixture {name}, use return instead of yield |
| [PT023] | use @pytest.mark.foo() over @pytest.mark.foo <br> (configurable by `pytest-mark-no-parentheses`) |
| [PT024] | pytest.mark.asyncio is unnecessary for fixtures |
| [PT025] | pytest.mark.usefixtures has no effect on fixtures |
| [PT026] | useless pytest.mark.usefixtures without parameters |
| [PT027] | use pytest.raises() instead of unittest-style '{assertion}' |
## Installation
pip install flake8-pytest-style
## Configuration
The plugin has the following configuration options:
* `pytest-fixture-no-parentheses` — see [PT001]
* `pytest-parametrize-names-type` — see [PT006]
* `pytest-parametrize-values-type` — see [PT007]
* `pytest-parametrize-values-row-type` — see [PT007]
* `pytest-raises-require-match-for` — see [PT011]
* `pytest-mark-no-parentheses` — see [PT023]
## For developers
### Install deps and setup pre-commit hook
make init
### Run linters, autoformat, tests etc.
make format lint test
### Bump new version
make bump_major
make bump_minor
make bump_patch
## License
MIT
## Change Log
**Unreleased**
...
**1.7.2 - 2023-02-15**
* fix false positive for [PT009] on `pytest.fail`
**1.7.1 - 2023-02-15**
* update list of unittest-style assert methods for [PT009]/[PT027]
**1.7.0 - 2023-02-09**
* require at least Python 3.7.2
* support Python 3.11
* add [PT027] (checks for unittest-style `assertRaises`)
**1.6.0 - 2021-12-23**
* require at least Python 3.6.2
* expose `py.typed` file
**1.5.1 - 2021-11-05**
* better wording for [PT011]
* support Python 3.10
**1.5.0 - 2021-06-18**
* add [PT025] (checks for erroneous `pytest.mark.usefixtures` on fixtures)
* add [PT026] (checks for `pytest.mark.usefixtures` without parameters)
**1.4.4 - 2021-06-17**
* fix [PT023] not checking marks in classes
* fix [PT004] incorrectly firing on fixtures with `yield from`
**1.4.2 - 2021-05-24**
* update `flake8-plugin-utils` version to improve stability
**1.4.1 - 2021-04-01**
* fix argparse-related warnings
**1.4.0 - 2021-03-14**
* add [PT023] (checks for parentheses consistency in `pytest.mark` usage)
* add [PT024] (checks for unnecessary `pytest.mark.asyncio` on fixtures)
* fix [PT004], [PT005] firing on abstract fixtures
* fix [PT012] firing on `with` statements containing a single `pass`
**1.3.0 - 2020-08-30**
* add [PT022] (checks for `yield` fixtures without teardown)
**1.2.3 - 2020-08-06**
* update `flake8-plugin-utils` dependency to fix encoding problems on Windows
**1.2.2 - 2020-07-23**
* fix [PT004]/[PT005] inspecting returns of nested functions
**1.2.1 - 2020-06-15**
* fix [PT021] for factory fixtures (#46)
**1.2.0 - 2020-06-12**
* support scoped `mocker` fixtures from `pytest-mock` for [PT008]
* check for positional-only lambda arguments in [PT008]
* add [PT020] (checks for `pytest.yield_fixture`)
* add [PT021] (checks for `request.addfinalizer`)
* add documentation pages for all rules
**1.1.1 - 2020-04-17**
* fix [PT011] not reporting `match=''` as a violation
**1.1.0 - 2020-04-14**
* add [PT015] (checks for `assert False`)
* add [PT016] (checks for `pytest.fail()` without message)
* add [PT017] (checks for assertions on exceptions in `except` blocks)
* add [PT018] (checks for composite assertions)
* add [PT019] (checks for fixtures without value injected as parameters)
**1.0.0 - 2020-03-26**
* add [PT014] (checks for duplicate test cases in `@pytest.mark.parametrize`)
**0.6.0 - 2020-03-21**
* add configuration option `pytest-parametrize-names-type` for [PT006]
* add configuration options `pytest-parametrize-values-type` and
`pytest-parametrize-values-row-type` for [PT007]
**0.5.0 - 2020-03-09**
* add configuration option `pytest-fixture-no-parentheses` for [PT001]
* add [PT013] (checks for `from`-imports from `pytest`)
**0.4.0 - 2020-03-09**
* add [PT012] (checks for multiple statements in `with pytest.raises()`)
**0.3.1 - 2020-03-09**
* fix default value of `pytest-raises-require-match-for` config option
**0.3.0 - 2020-03-09**
* add [PT010] and [PT011] (checks for `pytest.raises` parameters)
**0.2.0 - 2020-03-01**
* add [PT009] (ported from [flake8-pytest](https://github.com/vikingco/flake8-pytest))
**0.1.3 - 2019-05-24**
* add `yield` fixtures support
* fix changelog entry for 0.1.2
**0.1.2 - 2019-05-23**
* fix parametrize checkers not working in decorators
**0.1.1 - 2019-05-23**
* update PyPI description
**0.1.0 - 2019-05-23**
* initial
[PT001]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT001.md
[PT002]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT002.md
[PT003]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT003.md
[PT004]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT004.md
[PT005]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT005.md
[PT006]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT006.md
[PT007]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT007.md
[PT008]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT008.md
[PT009]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT009.md
[PT010]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT010.md
[PT011]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT011.md
[PT012]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT012.md
[PT013]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT013.md
[PT014]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT014.md
[PT015]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT015.md
[PT016]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT016.md
[PT017]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT017.md
[PT018]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT018.md
[PT019]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT019.md
[PT020]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT020.md
[PT021]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT021.md
[PT022]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT022.md
[PT023]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT023.md
[PT024]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT024.md
[PT025]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT025.md
[PT026]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT026.md
[PT027]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT027.md
%package -n python3-flake8-pytest-style
Summary: A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
Provides: python-flake8-pytest-style
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-flake8-pytest-style
# flake8-pytest-style
[](https://pypi.org/project/flake8-pytest-style)
[](https://pypi.org/project/flake8-pytest-style)
[](https://pypistats.org/packages/flake8-pytest-style)
[](https://github.com/m-burst/flake8-pytest-style/actions/workflows/ci.yml)
[](https://codecov.io/gh/m-burst/flake8-pytest-style)
[](https://en.wikipedia.org/wiki/MIT_License)
[](https://github.com/ambv/black)
## Description
A `flake8` plugin checking common style issues or inconsistencies with `pytest`-based tests.
Currently the following errors are reported:
| Code | Description |
| ------- | ----------- |
| [PT001] | use @pytest.fixture() over @pytest.fixture <br> (configurable by `pytest-fixture-no-parentheses`) |
| [PT002] | configuration for fixture '{name}' specified via positional args, use kwargs |
| [PT003] | scope='function' is implied in @pytest.fixture() |
| [PT004] | fixture '{name}' does not return anything, add leading underscore |
| [PT005] | fixture '{name}' returns a value, remove leading underscore |
| [PT006] | wrong name(s) type in @pytest.mark.parametrize, expected {expected_type} <br> (configurable by `pytest-parametrize-names-type`) |
| [PT007] | wrong values type in @pytest.mark.parametrize, expected {expected_type} <br> (configurable by `pytest-parametrize-values-type` and `pytest-parametrize-values-row-type`) |
| [PT008] | use return_value= instead of patching with lambda |
| [PT009] | use a regular assert instead of unittest-style '{assertion}' |
| [PT010] | set the expected exception in pytest.raises() |
| [PT011] | pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception <br> (configurable by `pytest-raises-require-match-for`) |
| [PT012] | pytest.raises() block should contain a single simple statement |
| [PT013] | found incorrect import of pytest, use simple 'import pytest' instead |
| [PT014] | found duplicate test cases {indexes} in @pytest.mark.parametrize |
| [PT015] | assertion always fails, replace with pytest.fail() |
| [PT016] | no message passed to pytest.fail() |
| [PT017] | found assertion on exception {name} in except block, use pytest.raises() instead |
| [PT018] | assertion should be broken down into multiple parts |
| [PT019] | fixture {name} without value is injected as parameter, use @pytest.mark.usefixtures instead |
| [PT020] | @pytest.yield_fixture is deprecated, use @pytest.fixture |
| [PT021] | use yield instead of request.addfinalizer |
| [PT022] | no teardown in fixture {name}, use return instead of yield |
| [PT023] | use @pytest.mark.foo() over @pytest.mark.foo <br> (configurable by `pytest-mark-no-parentheses`) |
| [PT024] | pytest.mark.asyncio is unnecessary for fixtures |
| [PT025] | pytest.mark.usefixtures has no effect on fixtures |
| [PT026] | useless pytest.mark.usefixtures without parameters |
| [PT027] | use pytest.raises() instead of unittest-style '{assertion}' |
## Installation
pip install flake8-pytest-style
## Configuration
The plugin has the following configuration options:
* `pytest-fixture-no-parentheses` — see [PT001]
* `pytest-parametrize-names-type` — see [PT006]
* `pytest-parametrize-values-type` — see [PT007]
* `pytest-parametrize-values-row-type` — see [PT007]
* `pytest-raises-require-match-for` — see [PT011]
* `pytest-mark-no-parentheses` — see [PT023]
## For developers
### Install deps and setup pre-commit hook
make init
### Run linters, autoformat, tests etc.
make format lint test
### Bump new version
make bump_major
make bump_minor
make bump_patch
## License
MIT
## Change Log
**Unreleased**
...
**1.7.2 - 2023-02-15**
* fix false positive for [PT009] on `pytest.fail`
**1.7.1 - 2023-02-15**
* update list of unittest-style assert methods for [PT009]/[PT027]
**1.7.0 - 2023-02-09**
* require at least Python 3.7.2
* support Python 3.11
* add [PT027] (checks for unittest-style `assertRaises`)
**1.6.0 - 2021-12-23**
* require at least Python 3.6.2
* expose `py.typed` file
**1.5.1 - 2021-11-05**
* better wording for [PT011]
* support Python 3.10
**1.5.0 - 2021-06-18**
* add [PT025] (checks for erroneous `pytest.mark.usefixtures` on fixtures)
* add [PT026] (checks for `pytest.mark.usefixtures` without parameters)
**1.4.4 - 2021-06-17**
* fix [PT023] not checking marks in classes
* fix [PT004] incorrectly firing on fixtures with `yield from`
**1.4.2 - 2021-05-24**
* update `flake8-plugin-utils` version to improve stability
**1.4.1 - 2021-04-01**
* fix argparse-related warnings
**1.4.0 - 2021-03-14**
* add [PT023] (checks for parentheses consistency in `pytest.mark` usage)
* add [PT024] (checks for unnecessary `pytest.mark.asyncio` on fixtures)
* fix [PT004], [PT005] firing on abstract fixtures
* fix [PT012] firing on `with` statements containing a single `pass`
**1.3.0 - 2020-08-30**
* add [PT022] (checks for `yield` fixtures without teardown)
**1.2.3 - 2020-08-06**
* update `flake8-plugin-utils` dependency to fix encoding problems on Windows
**1.2.2 - 2020-07-23**
* fix [PT004]/[PT005] inspecting returns of nested functions
**1.2.1 - 2020-06-15**
* fix [PT021] for factory fixtures (#46)
**1.2.0 - 2020-06-12**
* support scoped `mocker` fixtures from `pytest-mock` for [PT008]
* check for positional-only lambda arguments in [PT008]
* add [PT020] (checks for `pytest.yield_fixture`)
* add [PT021] (checks for `request.addfinalizer`)
* add documentation pages for all rules
**1.1.1 - 2020-04-17**
* fix [PT011] not reporting `match=''` as a violation
**1.1.0 - 2020-04-14**
* add [PT015] (checks for `assert False`)
* add [PT016] (checks for `pytest.fail()` without message)
* add [PT017] (checks for assertions on exceptions in `except` blocks)
* add [PT018] (checks for composite assertions)
* add [PT019] (checks for fixtures without value injected as parameters)
**1.0.0 - 2020-03-26**
* add [PT014] (checks for duplicate test cases in `@pytest.mark.parametrize`)
**0.6.0 - 2020-03-21**
* add configuration option `pytest-parametrize-names-type` for [PT006]
* add configuration options `pytest-parametrize-values-type` and
`pytest-parametrize-values-row-type` for [PT007]
**0.5.0 - 2020-03-09**
* add configuration option `pytest-fixture-no-parentheses` for [PT001]
* add [PT013] (checks for `from`-imports from `pytest`)
**0.4.0 - 2020-03-09**
* add [PT012] (checks for multiple statements in `with pytest.raises()`)
**0.3.1 - 2020-03-09**
* fix default value of `pytest-raises-require-match-for` config option
**0.3.0 - 2020-03-09**
* add [PT010] and [PT011] (checks for `pytest.raises` parameters)
**0.2.0 - 2020-03-01**
* add [PT009] (ported from [flake8-pytest](https://github.com/vikingco/flake8-pytest))
**0.1.3 - 2019-05-24**
* add `yield` fixtures support
* fix changelog entry for 0.1.2
**0.1.2 - 2019-05-23**
* fix parametrize checkers not working in decorators
**0.1.1 - 2019-05-23**
* update PyPI description
**0.1.0 - 2019-05-23**
* initial
[PT001]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT001.md
[PT002]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT002.md
[PT003]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT003.md
[PT004]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT004.md
[PT005]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT005.md
[PT006]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT006.md
[PT007]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT007.md
[PT008]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT008.md
[PT009]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT009.md
[PT010]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT010.md
[PT011]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT011.md
[PT012]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT012.md
[PT013]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT013.md
[PT014]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT014.md
[PT015]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT015.md
[PT016]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT016.md
[PT017]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT017.md
[PT018]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT018.md
[PT019]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT019.md
[PT020]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT020.md
[PT021]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT021.md
[PT022]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT022.md
[PT023]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT023.md
[PT024]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT024.md
[PT025]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT025.md
[PT026]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT026.md
[PT027]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT027.md
%package help
Summary: Development documents and examples for flake8-pytest-style
Provides: python3-flake8-pytest-style-doc
%description help
# flake8-pytest-style
[](https://pypi.org/project/flake8-pytest-style)
[](https://pypi.org/project/flake8-pytest-style)
[](https://pypistats.org/packages/flake8-pytest-style)
[](https://github.com/m-burst/flake8-pytest-style/actions/workflows/ci.yml)
[](https://codecov.io/gh/m-burst/flake8-pytest-style)
[](https://en.wikipedia.org/wiki/MIT_License)
[](https://github.com/ambv/black)
## Description
A `flake8` plugin checking common style issues or inconsistencies with `pytest`-based tests.
Currently the following errors are reported:
| Code | Description |
| ------- | ----------- |
| [PT001] | use @pytest.fixture() over @pytest.fixture <br> (configurable by `pytest-fixture-no-parentheses`) |
| [PT002] | configuration for fixture '{name}' specified via positional args, use kwargs |
| [PT003] | scope='function' is implied in @pytest.fixture() |
| [PT004] | fixture '{name}' does not return anything, add leading underscore |
| [PT005] | fixture '{name}' returns a value, remove leading underscore |
| [PT006] | wrong name(s) type in @pytest.mark.parametrize, expected {expected_type} <br> (configurable by `pytest-parametrize-names-type`) |
| [PT007] | wrong values type in @pytest.mark.parametrize, expected {expected_type} <br> (configurable by `pytest-parametrize-values-type` and `pytest-parametrize-values-row-type`) |
| [PT008] | use return_value= instead of patching with lambda |
| [PT009] | use a regular assert instead of unittest-style '{assertion}' |
| [PT010] | set the expected exception in pytest.raises() |
| [PT011] | pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception <br> (configurable by `pytest-raises-require-match-for`) |
| [PT012] | pytest.raises() block should contain a single simple statement |
| [PT013] | found incorrect import of pytest, use simple 'import pytest' instead |
| [PT014] | found duplicate test cases {indexes} in @pytest.mark.parametrize |
| [PT015] | assertion always fails, replace with pytest.fail() |
| [PT016] | no message passed to pytest.fail() |
| [PT017] | found assertion on exception {name} in except block, use pytest.raises() instead |
| [PT018] | assertion should be broken down into multiple parts |
| [PT019] | fixture {name} without value is injected as parameter, use @pytest.mark.usefixtures instead |
| [PT020] | @pytest.yield_fixture is deprecated, use @pytest.fixture |
| [PT021] | use yield instead of request.addfinalizer |
| [PT022] | no teardown in fixture {name}, use return instead of yield |
| [PT023] | use @pytest.mark.foo() over @pytest.mark.foo <br> (configurable by `pytest-mark-no-parentheses`) |
| [PT024] | pytest.mark.asyncio is unnecessary for fixtures |
| [PT025] | pytest.mark.usefixtures has no effect on fixtures |
| [PT026] | useless pytest.mark.usefixtures without parameters |
| [PT027] | use pytest.raises() instead of unittest-style '{assertion}' |
## Installation
pip install flake8-pytest-style
## Configuration
The plugin has the following configuration options:
* `pytest-fixture-no-parentheses` — see [PT001]
* `pytest-parametrize-names-type` — see [PT006]
* `pytest-parametrize-values-type` — see [PT007]
* `pytest-parametrize-values-row-type` — see [PT007]
* `pytest-raises-require-match-for` — see [PT011]
* `pytest-mark-no-parentheses` — see [PT023]
## For developers
### Install deps and setup pre-commit hook
make init
### Run linters, autoformat, tests etc.
make format lint test
### Bump new version
make bump_major
make bump_minor
make bump_patch
## License
MIT
## Change Log
**Unreleased**
...
**1.7.2 - 2023-02-15**
* fix false positive for [PT009] on `pytest.fail`
**1.7.1 - 2023-02-15**
* update list of unittest-style assert methods for [PT009]/[PT027]
**1.7.0 - 2023-02-09**
* require at least Python 3.7.2
* support Python 3.11
* add [PT027] (checks for unittest-style `assertRaises`)
**1.6.0 - 2021-12-23**
* require at least Python 3.6.2
* expose `py.typed` file
**1.5.1 - 2021-11-05**
* better wording for [PT011]
* support Python 3.10
**1.5.0 - 2021-06-18**
* add [PT025] (checks for erroneous `pytest.mark.usefixtures` on fixtures)
* add [PT026] (checks for `pytest.mark.usefixtures` without parameters)
**1.4.4 - 2021-06-17**
* fix [PT023] not checking marks in classes
* fix [PT004] incorrectly firing on fixtures with `yield from`
**1.4.2 - 2021-05-24**
* update `flake8-plugin-utils` version to improve stability
**1.4.1 - 2021-04-01**
* fix argparse-related warnings
**1.4.0 - 2021-03-14**
* add [PT023] (checks for parentheses consistency in `pytest.mark` usage)
* add [PT024] (checks for unnecessary `pytest.mark.asyncio` on fixtures)
* fix [PT004], [PT005] firing on abstract fixtures
* fix [PT012] firing on `with` statements containing a single `pass`
**1.3.0 - 2020-08-30**
* add [PT022] (checks for `yield` fixtures without teardown)
**1.2.3 - 2020-08-06**
* update `flake8-plugin-utils` dependency to fix encoding problems on Windows
**1.2.2 - 2020-07-23**
* fix [PT004]/[PT005] inspecting returns of nested functions
**1.2.1 - 2020-06-15**
* fix [PT021] for factory fixtures (#46)
**1.2.0 - 2020-06-12**
* support scoped `mocker` fixtures from `pytest-mock` for [PT008]
* check for positional-only lambda arguments in [PT008]
* add [PT020] (checks for `pytest.yield_fixture`)
* add [PT021] (checks for `request.addfinalizer`)
* add documentation pages for all rules
**1.1.1 - 2020-04-17**
* fix [PT011] not reporting `match=''` as a violation
**1.1.0 - 2020-04-14**
* add [PT015] (checks for `assert False`)
* add [PT016] (checks for `pytest.fail()` without message)
* add [PT017] (checks for assertions on exceptions in `except` blocks)
* add [PT018] (checks for composite assertions)
* add [PT019] (checks for fixtures without value injected as parameters)
**1.0.0 - 2020-03-26**
* add [PT014] (checks for duplicate test cases in `@pytest.mark.parametrize`)
**0.6.0 - 2020-03-21**
* add configuration option `pytest-parametrize-names-type` for [PT006]
* add configuration options `pytest-parametrize-values-type` and
`pytest-parametrize-values-row-type` for [PT007]
**0.5.0 - 2020-03-09**
* add configuration option `pytest-fixture-no-parentheses` for [PT001]
* add [PT013] (checks for `from`-imports from `pytest`)
**0.4.0 - 2020-03-09**
* add [PT012] (checks for multiple statements in `with pytest.raises()`)
**0.3.1 - 2020-03-09**
* fix default value of `pytest-raises-require-match-for` config option
**0.3.0 - 2020-03-09**
* add [PT010] and [PT011] (checks for `pytest.raises` parameters)
**0.2.0 - 2020-03-01**
* add [PT009] (ported from [flake8-pytest](https://github.com/vikingco/flake8-pytest))
**0.1.3 - 2019-05-24**
* add `yield` fixtures support
* fix changelog entry for 0.1.2
**0.1.2 - 2019-05-23**
* fix parametrize checkers not working in decorators
**0.1.1 - 2019-05-23**
* update PyPI description
**0.1.0 - 2019-05-23**
* initial
[PT001]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT001.md
[PT002]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT002.md
[PT003]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT003.md
[PT004]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT004.md
[PT005]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT005.md
[PT006]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT006.md
[PT007]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT007.md
[PT008]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT008.md
[PT009]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT009.md
[PT010]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT010.md
[PT011]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT011.md
[PT012]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT012.md
[PT013]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT013.md
[PT014]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT014.md
[PT015]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT015.md
[PT016]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT016.md
[PT017]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT017.md
[PT018]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT018.md
[PT019]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT019.md
[PT020]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT020.md
[PT021]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT021.md
[PT022]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT022.md
[PT023]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT023.md
[PT024]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT024.md
[PT025]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT025.md
[PT026]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT026.md
[PT027]: https://github.com/m-burst/flake8-pytest-style/blob/v1.7.2/docs/rules/PT027.md
%prep
%autosetup -n flake8-pytest-style-1.7.2
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-flake8-pytest-style -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 1.7.2-1
- Package Spec generated
|