fixtures: remove an unneeded suppress
In `CallSpec2.setmulti` the `params` and `_arg2scope` dicts are always set together. Further, the `get_parametrized_fixture_keys` accesses `_arg2scope` for all argnames without a check, which I think rules out that the code protects against plugin shenanigans. After removing the suppress, adjust the comment and code to make more sense.
This commit is contained in:
		
							parent
							
								
									010ce2ab0f
								
							
						
					
					
						commit
						ad651ddfce
					
				| 
						 | 
					@ -2,7 +2,6 @@
 | 
				
			||||||
import abc
 | 
					import abc
 | 
				
			||||||
from collections import defaultdict
 | 
					from collections import defaultdict
 | 
				
			||||||
from collections import deque
 | 
					from collections import deque
 | 
				
			||||||
from contextlib import suppress
 | 
					 | 
				
			||||||
import dataclasses
 | 
					import dataclasses
 | 
				
			||||||
import functools
 | 
					import functools
 | 
				
			||||||
import inspect
 | 
					import inspect
 | 
				
			||||||
| 
						 | 
					@ -578,7 +577,6 @@ class FixtureRequest(abc.ABC):
 | 
				
			||||||
        # (latter managed by fixturedef)
 | 
					        # (latter managed by fixturedef)
 | 
				
			||||||
        argname = fixturedef.argname
 | 
					        argname = fixturedef.argname
 | 
				
			||||||
        funcitem = self._pyfuncitem
 | 
					        funcitem = self._pyfuncitem
 | 
				
			||||||
        scope = fixturedef._scope
 | 
					 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            callspec = funcitem.callspec
 | 
					            callspec = funcitem.callspec
 | 
				
			||||||
        except AttributeError:
 | 
					        except AttributeError:
 | 
				
			||||||
| 
						 | 
					@ -586,13 +584,13 @@ class FixtureRequest(abc.ABC):
 | 
				
			||||||
        if callspec is not None and argname in callspec.params:
 | 
					        if callspec is not None and argname in callspec.params:
 | 
				
			||||||
            param = callspec.params[argname]
 | 
					            param = callspec.params[argname]
 | 
				
			||||||
            param_index = callspec.indices[argname]
 | 
					            param_index = callspec.indices[argname]
 | 
				
			||||||
            # If a parametrize invocation set a scope it will override
 | 
					            # The parametrize invocation scope overrides the fixture's scope.
 | 
				
			||||||
            # the static scope defined with the fixture function.
 | 
					            scope = callspec._arg2scope[argname]
 | 
				
			||||||
            with suppress(KeyError):
 | 
					 | 
				
			||||||
                scope = callspec._arg2scope[argname]
 | 
					 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            param = NOTSET
 | 
					            param = NOTSET
 | 
				
			||||||
            param_index = 0
 | 
					            param_index = 0
 | 
				
			||||||
 | 
					            scope = fixturedef._scope
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            has_params = fixturedef.params is not None
 | 
					            has_params = fixturedef.params is not None
 | 
				
			||||||
            fixtures_not_supported = getattr(funcitem, "nofuncargs", False)
 | 
					            fixtures_not_supported = getattr(funcitem, "nofuncargs", False)
 | 
				
			||||||
            if has_params and fixtures_not_supported:
 | 
					            if has_params and fixtures_not_supported:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue