Skip to content

Commit

Permalink
Skip layer-based tests inside 'setup.py test'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed May 17, 2013
1 parent 58b8436 commit f932aed
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ def _modname(path, base, name=''):
dirname, basename = os.path.split(path)
return _modname(dirname, base, basename + '.' + name)

def _flatten(suite, predicate=lambda *x: True):
from unittest import TestCase
for suite_or_case in suite:
if predicate(suite_or_case):
if isinstance(suite_or_case, TestCase):
yield suite_or_case
else:
for x in _flatten(suite_or_case):
yield x

def _no_layer(suite_or_case):
return getattr(suite_or_case, 'layer', None) is None

def _unittests_only(suite, mod_suite):
for case in _flatten(mod_suite, _no_layer):
suite.addTest(case)

def alltests():
import logging
import pkg_resources
Expand All @@ -70,7 +87,7 @@ def emit(self, record):
mod = __import__(
_modname(dirpath, base, os.path.splitext(filename)[0]),
{}, {}, ['*'])
suite.addTest(mod.test_suite())
_unittests_only(suite, mod.test_suite())
return suite

tests_require = ['zope.testing', 'manuel', 'random2']
Expand Down

1 comment on commit f932aed

@mgedmin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there value from having python setup.py test run an incomplete test suite?

zope.testrunner's setup.py overrides the setuptools 'test' command and uses itself to run the tests. We could do the same thing here.

Please sign in to comment.