Skip to content

Commit

Permalink
- Fix SkipLayers class in cases where the distribution specifies a
Browse files Browse the repository at this point in the history
  ``test_suite`` value.
  • Loading branch information
strichter committed Mar 3, 2013
1 parent 541911a commit a3988b0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ zope.testrunner Changelog
4.3.2 (unreleased)
==================

- Nothing changed yet.
- Fix ``SkipLayers`` class in cases where the distribution specifies a
``test_suite`` value.


4.3.1 (2013-03-02)
Expand Down
8 changes: 7 additions & 1 deletion src/zope/testrunner/eggsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ class SkipLayers(ScanningLoader):
)
"""
def loadTestsFromModule(self, module):
return skipLayers(ScanningLoader.loadTestsFromModule(self, module))
return skipLayers(
ScanningLoader.loadTestsFromModule(self, module))

def loadTestsFromNames(self, testNames, module):
return skipLayers(
ScanningLoader.loadTestsFromNames(self, testNames, module))


def print_usage():
print('python setup.py ftest')
Expand Down
24 changes: 24 additions & 0 deletions src/zope/testrunner/testrunner-eggsupport.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,27 @@ Now we can retrieve the modules from the layer skipping loader:
Cleanup:

>>> ScanningLoader.loadTestsFromModule = orig_loadTestsFromModule

When the distribution specified a ``test_suite``, another method is used to
load the tests.

>>> orig_loadTestsFromNames = ScanningLoader.loadTestsFromNames
>>> ScanningLoader.loadTestsFromNames = lambda *args: all

Now we can retrieve the modules from the layer skipping loader:

>>> from zope.testrunner.eggsupport import SkipLayers
>>> filtered = SkipLayers().loadTestsFromNames(
... 'zope.testrunner.tests.test_suite', 'zope.testrunner')

>>> len(filtered._tests)
3
>>> from pprint import pprint
>>> pprint(filtered._tests)
[<...T1 testMethod=test_t1>,
StartUpFailure (zope.testrunner.find),
.../zope/testrunner/testrunner.txt]

Cleanup:

>>> ScanningLoader.loadTestsFromNames = orig_loadTestsFromNames

0 comments on commit a3988b0

Please sign in to comment.