MCPcopy Index your code
hub / github.com/python/cpython / test___name__

Method test___name__

Lib/test/test_funcattrs.py:186–200  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

184 print(a)
185
186 def test___name__(self):
187 self.assertEqual(self.b.__name__, 'b')
188 self.b.__name__ = 'c'
189 self.assertEqual(self.b.__name__, 'c')
190 self.b.__name__ = 'd'
191 self.assertEqual(self.b.__name__, 'd')
192 # __name__ and __name__ must be a string
193 self.cannot_set_attr(self.b, '__name__', 7, TypeError)
194 # __name__ must be available when in restricted mode. Exec will raise
195 # AttributeError if __name__ is not available on f.
196 s = """def f(): pass\nf.__name__"""
197 exec(s, {'__builtins__': {}})
198 # Test on methods, too
199 self.assertEqual(self.fi.a.__name__, 'a')
200 self.cannot_set_attr(self.fi.a, "__name__", 'a', AttributeError)
201
202 def test___qualname__(self):
203 # PEP 3155

Callers

nothing calls this directly

Calls 2

cannot_set_attrMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected