pytestconf.py
brancholdstable
changeset 5993 50e1a6ad3e98
parent 5906 d40ced753291
child 9471 367fe83d9f98
equal deleted inserted replaced
5487:3ab2682a4b37 5993:50e1a6ad3e98
    20 """
    20 """
    21 import sys
    21 import sys
    22 from os.path import split, splitext
    22 from os.path import split, splitext
    23 from logilab.common.pytest import PyTester
    23 from logilab.common.pytest import PyTester
    24 
    24 
    25 from cubicweb.etwist.server import _gc_debug
       
    26 
       
    27 class CustomPyTester(PyTester):
    25 class CustomPyTester(PyTester):
    28     def testfile(self, filename, batchmode=False):
    26     def testfile(self, filename, batchmode=False):
    29         try:
    27         try:
    30             return super(CustomPyTester, self).testfile(filename, batchmode)
    28             return super(CustomPyTester, self).testfile(filename, batchmode)
    31         finally:
    29         finally:
    37                 return
    35                 return
    38             for cls in vars(module).values():
    36             for cls in vars(module).values():
    39                 if getattr(cls, '__module__', None) != modname:
    37                 if getattr(cls, '__module__', None) != modname:
    40                     continue
    38                     continue
    41                 clean_repo_test_cls(cls)
    39                 clean_repo_test_cls(cls)
    42             #_gc_debug()
       
    43 
    40 
    44 def clean_repo_test_cls(cls):
    41 def clean_repo_test_cls(cls):
    45     if 'repo' in cls.__dict__:
    42     if 'repo' in cls.__dict__:
    46         if not cls.repo._shutting_down:
    43         if not cls.repo.shutting_down:
    47             cls.repo.shutdown()
    44             cls.repo.shutdown()
    48         del cls.repo
    45         del cls.repo
    49     for clsattr in ('cnx', '_orig_cnx', 'config', '_config', 'vreg', 'schema'):
    46     for clsattr in ('cnx', '_orig_cnx', 'config', '_config', 'vreg', 'schema'):
    50         if clsattr in cls.__dict__:
    47         if clsattr in cls.__dict__:
    51             delattr(cls, clsattr)
    48             delattr(cls, clsattr)