aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_test.py
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2017-06-26 18:28:07 +0200
committerBenoit Pierre <benoit.pierre@gmail.com>2017-11-02 20:58:42 +0100
commit803707a68f228f452703333cbf75708938c2eb9e (patch)
tree5de0452049eff086ad8ae3c3b71fb58a6c665f1c /setuptools/tests/test_test.py
parentb5d00314293e400bc72f3699e428f168ac74d824 (diff)
downloadexternal_python_setuptools-803707a68f228f452703333cbf75708938c2eb9e.tar.gz
external_python_setuptools-803707a68f228f452703333cbf75708938c2eb9e.tar.bz2
external_python_setuptools-803707a68f228f452703333cbf75708938c2eb9e.zip
tests: check `test` command run tests only once
Diffstat (limited to 'setuptools/tests/test_test.py')
-rw-r--r--setuptools/tests/test_test.py43
1 files changed, 41 insertions, 2 deletions
diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py
index 02cba00d..960527bc 100644
--- a/setuptools/tests/test_test.py
+++ b/setuptools/tests/test_test.py
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
from distutils import log
import os
+import sys
import pytest
@@ -66,13 +67,13 @@ def sample_test(tmpdir_cwd):
@pytest.fixture
-def silent_log():
+def quiet_log():
# Running some of the other tests will automatically
# change the log level to info, messing our output.
log.set_verbosity(0)
-@pytest.mark.usefixtures('sample_test', 'silent_log')
+@pytest.mark.usefixtures('sample_test', 'quiet_log')
def test_test(capfd):
params = dict(
name='foo',
@@ -90,3 +91,41 @@ def test_test(capfd):
cmd.run()
out, err = capfd.readouterr()
assert out == 'Foo\n'
+
+
+@pytest.mark.xfail(
+ sys.version_info < (2, 7),
+ reason="No discover support for unittest on Python 2.6",
+)
+@pytest.mark.usefixtures('tmpdir_cwd', 'quiet_log')
+def test_tests_are_run_once(capfd):
+ params = dict(
+ name='foo',
+ packages=['dummy'],
+ )
+ with open('setup.py', 'wt') as f:
+ f.write('from setuptools import setup; setup(\n')
+ for k, v in sorted(params.items()):
+ f.write(' %s=%r,\n' % (k, v))
+ f.write(')\n')
+ os.makedirs('dummy')
+ with open('dummy/__init__.py', 'wt'):
+ pass
+ with open('dummy/test_dummy.py', 'wt') as f:
+ f.write(DALS(
+ """
+ from __future__ import print_function
+ import unittest
+ class TestTest(unittest.TestCase):
+ def test_test(self):
+ print('Foo')
+ """))
+ dist = Distribution(params)
+ dist.script_name = 'setup.py'
+ cmd = test(dist)
+ cmd.ensure_finalized()
+ # The test runner calls sys.exit
+ with contexts.suppress_exceptions(SystemExit):
+ cmd.run()
+ out, err = capfd.readouterr()
+ assert out == 'Foo\n'