From 91f7cd51b68822000ec1d67e22d52c4411650633 Mon Sep 17 00:00:00 2001 From: Eldar Abusalimov Date: Fri, 24 Oct 2014 14:10:44 +0400 Subject: [PATCH 01/15] (minor) test_mro: test case stub and helpers --- Lib/test/test_mro.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Lib/test/test_mro.py diff --git a/Lib/test/test_mro.py b/Lib/test/test_mro.py new file mode 100644 index 0000000..106c23b --- /dev/null +++ b/Lib/test/test_mro.py @@ -0,0 +1,42 @@ +""" +Tests for metaclass mro() method and friends. +""" + +__author__ = "Eldar Abusalimov " + +import unittest + + +class DebugHelperMeta(type): + """ + Sets default __doc__ and simplifies repr() output. + """ + def __new__(mcls, name, bases, attrs): + if attrs.get('__doc__') is None: + attrs['__doc__'] = name # helps when debugging with gdb + return type.__new__(mcls, name, bases, attrs) + def __repr__(cls): + return repr(cls.__name__) + + +class MroTest(unittest.TestCase): + """ + Regressions for some bugs revealed through + mcsl.mro() customization (typeobject.c: mro_internal()) and + cls.__bases__ assignment (typeobject.c: type_set_bases()). + """ + + def setUp(self): + self.step = 0 + self.ready = False + + def step_until(self, limit): + ret = (self.step < limit) + if ret: + self.step += 1 + return ret + + +if __name__ == '__main__': + unittest.main() + -- 2.1.1