Skip to content

Commit

Permalink
Merge pull request #96 from cjwatson/fix-require-unique-warning
Browse files Browse the repository at this point in the history
Prevent spurious --require-unique warnings
  • Loading branch information
cjwatson committed Oct 13, 2019
2 parents 609245f + 6d3ff04 commit 105173b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -8,6 +8,9 @@
- Recover more gracefully when layer setUp or tearDown fails, producing
useful subunit output.

- Prevent a spurious warning from the ``--require-unique`` option if the
``--module`` option was not used.


5.0 (2019-03-19)
================
Expand Down
3 changes: 2 additions & 1 deletion src/zope/testrunner/options.py
Expand Up @@ -628,6 +628,7 @@ def apply_auto_progress(args):

options.ignore_dir = set(options.ignore_dir)
options.test = options.test or ['.']
module_set = bool(options.module)
options.module = options.module or ['.']

options.path = options.path or []
Expand Down Expand Up @@ -694,7 +695,7 @@ def apply_auto_progress(args):
options.fail = True
return options

if options.module and options.require_unique_ids:
if module_set and options.require_unique_ids:
# We warn if --module and --require-unique are specified at the same
# time, though we don't exit.
print("""\
Expand Down
27 changes: 27 additions & 0 deletions src/zope/testrunner/tests/testrunner-edge-cases.rst
Expand Up @@ -524,3 +524,30 @@ Several tests can be excluded using the '!' notation:
Tearing down left over layers:
Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
False


Requiring unique test IDs
-------------------------

The --require-unique option causes the test runner to require that all test
IDs be unique. Its behaviour is tested in zope.testrunner.tests.test_find;
here we check its interaction with other options.

The --require-unique option does not issue any warnings on its own.

>>> sys.argv = 'test --require-unique'.split()
>>> testrunner.run_internal(defaults)
... # doctest: +ELLIPSIS
Running zope.testrunner.layer.UnitTests tests:
...

Attempting to use both --module and --require-unique issues a warning.

>>> sys.argv = 'test --module sample --require-unique'.split()
>>> testrunner.run_internal(defaults)
... # doctest: +ELLIPSIS
You specified a module along with --require-unique;
--require-unique will not try to enforce test ID uniqueness when
working with a specific module.
Running zope.testrunner.layer.UnitTests tests:
...

0 comments on commit 105173b

Please sign in to comment.