Access attributes to return a named object, usable as a sentinel.
| 324 | |
| 325 | |
| 326 | class _Sentinel(object): |
| 327 | """Access attributes to return a named object, usable as a sentinel.""" |
| 328 | def __init__(self): |
| 329 | self._sentinels = {} |
| 330 | |
| 331 | def __getattr__(self, name): |
| 332 | if name == '__bases__': |
| 333 | # Without this help(unittest.mock) raises an exception |
| 334 | raise AttributeError |
| 335 | return self._sentinels.setdefault(name, _SentinelObject(name)) |
| 336 | |
| 337 | def __reduce__(self): |
| 338 | return 'sentinel' |
| 339 | |
| 340 | |
| 341 | sentinel = _Sentinel() |
no outgoing calls
no test coverage detected
searching dependent graphs…