File tree 2 files changed +7
-1
lines changed
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def qualname_from_frame(frame):
48
48
fname = co .co_name
49
49
method = None
50
50
if co .co_argcount and co .co_varnames [0 ] == "self" :
51
- self = frame .f_locals [ "self" ]
51
+ self = frame .f_locals . get ( "self" , None )
52
52
method = getattr (self , fname , None )
53
53
54
54
if method is None :
Original file line number Diff line number Diff line change 5
5
6
6
import inspect
7
7
import os .path
8
+ from unittest import mock
8
9
9
10
import coverage
10
11
from coverage .context import qualname_from_frame
@@ -275,3 +276,8 @@ def test_bug_829(self):
275
276
# A class with a name like a function shouldn't confuse qualname_from_frame.
276
277
class test_something : # pylint: disable=unused-variable
277
278
assert get_qualname () is None
279
+
280
+ def test_bug_1210 (self ):
281
+ co = mock .Mock (co_name = "a_co_name" , co_argcount = 1 , co_varnames = ["self" ])
282
+ frame = mock .Mock (f_code = co , f_locals = {})
283
+ assert qualname_from_frame (frame ) == "unittest.mock.a_co_name"
You can’t perform that action at this time.
0 commit comments