File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
10
10
write_to = " src/_pytest/_version.py"
11
11
12
12
[tool .pytest .ini_options ]
13
- # minversion = "2.0"
13
+ minversion = " 2.0"
14
14
addopts = " -rfEX -p pytester --strict-markers"
15
15
python_files = [" test_*.py" , " *_test.py" , " testing/python/*.py" ]
16
16
python_classes = [" Test" , " Acceptance" ]
Original file line number Diff line number Diff line change @@ -206,20 +206,17 @@ def __len__(self) -> int:
206
206
return len (self ._list )
207
207
208
208
def pop (self , cls : Type [Warning ] = Warning ) -> "warnings.WarningMessage" :
209
- """Pop the first recorded warning which is an instance of ``cls``.
210
-
211
- But not an instance of a child class of any other match.
209
+ """Pop the first recorded warning which is an instance of ``cls``,
210
+ but not an instance of a child class of any other match.
212
211
Raises ``AssertionError`` if there is no match.
213
-
214
212
"""
215
-
216
- best_idx = None
213
+ best_idx : Optional [int ] = None
217
214
for i , w in enumerate (self ._list ):
218
215
if w .category == cls :
219
216
return self ._list .pop (i ) # exact match, stop looking
220
217
if issubclass (w .category , cls ) and (
221
218
best_idx is None
222
- or not issubclass (w .category , self ._list [best_idx ].category ) # type: ignore[unreachable]
219
+ or not issubclass (w .category , self ._list [best_idx ].category )
223
220
):
224
221
best_idx = i
225
222
if best_idx is not None :
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ def raise_warnings_from_list(_warnings: List[Type[Warning]]):
54
54
for warn in _warnings :
55
55
warnings .warn (f"Warning { warn ().__repr__ ()} " , warn )
56
56
57
- def test_pop (self ):
57
+ def test_pop_finds_exact_match (self ):
58
58
with pytest .warns ((self .ParentWarning , self .ChildWarning )) as record :
59
59
self .raise_warnings_from_list (
60
60
[self .ChildWarning , self .ParentWarning , self .ChildOfChildWarning ]
@@ -64,13 +64,13 @@ def test_pop(self):
64
64
_warn = record .pop (self .ParentWarning )
65
65
assert _warn .category is self .ParentWarning
66
66
67
- def test_pop_raises (self ):
67
+ def test_pop_raises_if_no_match (self ):
68
68
with pytest .raises (AssertionError ):
69
69
with pytest .warns (self .ParentWarning ) as record :
70
70
self .raise_warnings_from_list ([self .ParentWarning ])
71
71
record .pop (self .ChildOfChildWarning )
72
72
73
- def test_pop_most_recent (self ):
73
+ def test_pop_finds_best_inexact_match (self ):
74
74
with pytest .warns (self .ParentWarning ) as record :
75
75
self .raise_warnings_from_list (
76
76
[self .ChildOfChildWarning , self .ChildWarning , self .ChildOfChildWarning ]
You can’t perform that action at this time.
0 commit comments