@@ -602,13 +602,9 @@ def _compute_fixture_value(self, fixturedef: "FixtureDef[object]") -> None:
602
602
fixtures_not_supported = getattr (funcitem , "nofuncargs" , False )
603
603
if has_params and fixtures_not_supported :
604
604
msg = (
605
- "{name} does not support fixtures, maybe unittest.TestCase subclass?\n "
606
- "Node id: {nodeid}\n "
607
- "Function type: {typename}"
608
- ).format (
609
- name = funcitem .name ,
610
- nodeid = funcitem .nodeid ,
611
- typename = type (funcitem ).__name__ ,
605
+ f"{ funcitem .name } does not support fixtures, maybe unittest.TestCase subclass?\n "
606
+ f"Node id: { funcitem .nodeid } \n "
607
+ f"Function type: { type (funcitem ).__name__ } "
612
608
)
613
609
fail (msg , pytrace = False )
614
610
if has_params :
@@ -741,9 +737,7 @@ def node(self):
741
737
if node is None and scope is Scope .Class :
742
738
# Fallback to function item itself.
743
739
node = self ._pyfuncitem
744
- assert node , 'Could not obtain a node for scope "{}" for function {!r}' .format (
745
- scope , self ._pyfuncitem
746
- )
740
+ assert node , f'Could not obtain a node for scope "{ scope } " for function { self ._pyfuncitem !r} '
747
741
return node
748
742
749
743
def _check_scope (
@@ -846,9 +840,7 @@ def formatrepr(self) -> "FixtureLookupErrorRepr":
846
840
if faclist :
847
841
available .add (name )
848
842
if self .argname in available :
849
- msg = " recursive dependency involving fixture '{}' detected" .format (
850
- self .argname
851
- )
843
+ msg = f" recursive dependency involving fixture '{ self .argname } ' detected"
852
844
else :
853
845
msg = f"fixture '{ self .argname } ' not found"
854
846
msg += "\n available fixtures: {}" .format (", " .join (sorted (available )))
@@ -941,15 +933,13 @@ def _eval_scope_callable(
941
933
result = scope_callable (fixture_name = fixture_name , config = config ) # type: ignore[call-arg]
942
934
except Exception as e :
943
935
raise TypeError (
944
- "Error evaluating {} while defining fixture '{}'.\n "
945
- "Expected a function with the signature (*, fixture_name, config)" .format (
946
- scope_callable , fixture_name
947
- )
936
+ f"Error evaluating { scope_callable } while defining fixture '{ fixture_name } '.\n "
937
+ "Expected a function with the signature (*, fixture_name, config)"
948
938
) from e
949
939
if not isinstance (result , str ):
950
940
fail (
951
- "Expected {} to return a 'str' while defining fixture '{}', but it returned:\n "
952
- "{ !r}". format ( scope_callable , fixture_name , result ) ,
941
+ f "Expected { scope_callable } to return a 'str' while defining fixture '{ fixture_name } ', but it returned:\n "
942
+ f" { result !r} " ,
953
943
pytrace = False ,
954
944
)
955
945
return result
@@ -1091,9 +1081,7 @@ def cache_key(self, request: SubRequest) -> object:
1091
1081
return request .param_index if not hasattr (request , "param" ) else request .param
1092
1082
1093
1083
def __repr__ (self ) -> str :
1094
- return "<FixtureDef argname={!r} scope={!r} baseid={!r}>" .format (
1095
- self .argname , self .scope , self .baseid
1096
- )
1084
+ return f"<FixtureDef argname={ self .argname !r} scope={ self .scope !r} baseid={ self .baseid !r} >"
1097
1085
1098
1086
1099
1087
def resolve_fixture_function (
@@ -1209,9 +1197,7 @@ def __call__(self, function: FixtureFunction) -> FixtureFunction:
1209
1197
if name == "request" :
1210
1198
location = getlocation (function )
1211
1199
fail (
1212
- "'request' is a reserved word for fixtures, use another name:\n {}" .format (
1213
- location
1214
- ),
1200
+ f"'request' is a reserved word for fixtures, use another name:\n { location } " ,
1215
1201
pytrace = False ,
1216
1202
)
1217
1203
0 commit comments