Message401099
What to do with comprehensions and classes? Corresponding code objects are not easily accessible and they do not have corresponding function. It would be difficult to use the locals of the frame with comprehensions.
Maybe use per-module registries of qualnames?
class MyAssertions:
def assertComplexState(self, inputs):
self.assertEqual('42', inputs[0], 'the input %s is not the right answer' % inputs)
__unittests = {'MyAssertions.assertComplexState'}
The frame is skipped if f_globals['__unittests'] contains co_qualname or any parents of co_qualname.
We can even add a decorator:
def assertion(func):
mod = sys.modules[func.__module__]
mod.__dict__.setdefault('__unittests', set())
mod.__setdefault.add(func.__qualname__)
return func |
|
Date |
User |
Action |
Args |
2021-09-05 17:45:39 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, purcell, amaury.forgeotdarc, rbcollins, michael.foord, dmalcolm, Julian |
2021-09-05 17:45:39 | serhiy.storchaka | set | messageid: <1630863939.88.0.0799780595915.issue1705520@roundup.psfhosted.org> |
2021-09-05 17:45:39 | serhiy.storchaka | link | issue1705520 messages |
2021-09-05 17:45:39 | serhiy.storchaka | create | |
|