MCPcopy Index your code
hub / github.com/ipython/ipython / SerialLiar

Class SerialLiar

tests/test_oinspect.py:167–182  ·  view source on GitHub ↗

Attribute accesses always get another copy of the same class. unittest.mock.call does something similar, but it's not ideal for testing as the failure mode is to eat all your RAM. This gives up after 10k levels.

Source from the content-addressed store, hash-verified

165
166
167class SerialLiar(object):
168 """Attribute accesses always get another copy of the same class.
169
170 unittest.mock.call does something similar, but it's not ideal for testing
171 as the failure mode is to eat all your RAM. This gives up after 10k levels.
172 """
173
174 def __init__(self, max_fibbing_twig, lies_told=0):
175 if lies_told > 10000:
176 raise RuntimeError("Nose too long, honesty is the best policy")
177 self.max_fibbing_twig = max_fibbing_twig
178 self.lies_told = lies_told
179 max_fibbing_twig[0] = max(max_fibbing_twig[0], lies_told)
180
181 def __getattr__(self, item):
182 return SerialLiar(self.max_fibbing_twig, self.lies_told + 1)
183
184
185# -----------------------------------------------------------------------------

Callers 2

__getattr__Method · 0.85
test_info_serialliarFunction · 0.85

Calls

no outgoing calls

Tested by 2

__getattr__Method · 0.68
test_info_serialliarFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…