in teamcity/nose_report.py [0:0]
def prepareTestLoader(self, loader):
"""Insert ourselves into loader calls to count tests.
The top-level loader call often returns lazy results, like a LazySuite.
This is a problem, as we would destroy the suite by iterating over it
to count the tests. Consequently, we monkey-patch the top-level loader
call to do the load twice: once for the actual test running and again
to yield something we can iterate over to do the count.
from https://github.com/erikrose/nose-progressive/
:type loader: nose.loader.TestLoader
"""
# TODO: If there's ever a practical need, also patch loader.suiteClass
# or even TestProgram.createTests. createTests seems to be main top-
# level caller of loader methods, and nose.core.collector() (which
# isn't even called in nose) is an alternate one.
#
# nose 1.3.4 contains required fix:
# Another fix for Python 3.4: Call super in LazySuite to access _removed_tests variable
if hasattr(loader, 'loadTestsFromNames') and nose.__versioninfo__ >= (1, 3, 4):
old_loadTestsFromNames = loader.loadTestsFromNames
def _loadTestsFromNames(*args, **kwargs):
suite = old_loadTestsFromNames(*args, **kwargs)
self.total_tests += suite.countTestCases()
# Clear out the loader's cache. Otherwise, it never finds any tests
# for the actual test run:
loader._visitedPaths = set()
return old_loadTestsFromNames(*args, **kwargs)
loader.loadTestsFromNames = _loadTestsFromNames