diff --git a/_pytest/main.py b/_pytest/main.py index 48f5bb6f2e2..5771a169999 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -687,7 +687,7 @@ def _tryconvertpyarg(self, x): # This method is sometimes invoked when AssertionRewritingHook, which # does not define a get_filename method, is already in place: try: - path = loader.get_filename() + path = loader.get_filename(x) except AttributeError: # Retrieve path from AssertionRewritingHook: path = loader.modules[x][0].co_filename