You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Options.namer property currently instantiates a StackFrameNamer via get_default_namer() even when the namer has been set by calling options.with_namer(n) and the created StackFrameNamer instance will never be used.
In my situation, this caused a noticeable performance hit that showed up under the profiler.
Please consider only calling get_default_namer() if the namer field has not been set.
Current state:
@property
def namer(self) -> Namer:
from approvaltests.namer.default_name import get_default_namer
namer = self.fields.get("namer", get_default_namer())
if hasattr(namer, "set_extension"):
namer.set_extension(self.for_file.file_extention)
return namer
Potential fix:
@property
def namer(self) -> Namer:
from approvaltests.namer.default_name import get_default_namer
namer = options.fields.get("namer", None)
if namer is None:
namer = get_default_namer()
if hasattr(namer, "set_extension"):
namer.set_extension(self.for_file.file_extention)
return namer
Workaround:
passing the namer explicitly to calls to verify bypasses the use of the Options.namer property
PS. I love ApprovalTests!
The text was updated successfully, but these errors were encountered:
The Options.namer property currently instantiates a StackFrameNamer via get_default_namer() even when the namer has been set by calling options.with_namer(n) and the created StackFrameNamer instance will never be used.
In my situation, this caused a noticeable performance hit that showed up under the profiler.
Please consider only calling get_default_namer() if the namer field has not been set.
Current state:
Potential fix:
Workaround:
passing the namer explicitly to calls to
verify
bypasses the use of the Options.namer propertyPS. I love ApprovalTests!
The text was updated successfully, but these errors were encountered: