aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/tests/test_test.py')
-rw-r--r--setuptools/tests/test_test.py86
1 files changed, 61 insertions, 25 deletions
diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py
index 7ea43c57..8d1425e1 100644
--- a/setuptools/tests/test_test.py
+++ b/setuptools/tests/test_test.py
@@ -2,9 +2,9 @@
from __future__ import unicode_literals
+from distutils import log
import os
-import site
-from distutils.errors import DistutilsError
+import sys
import pytest
@@ -66,26 +66,62 @@ def sample_test(tmpdir_cwd):
f.write(TEST_PY)
-@pytest.mark.skipif('hasattr(sys, "real_prefix")')
-@pytest.mark.usefixtures('user_override')
-@pytest.mark.usefixtures('sample_test')
-class TestTestTest:
- def test_test(self):
- params = dict(
- name='foo',
- packages=['name', 'name.space', 'name.space.tests'],
- namespace_packages=['name'],
- test_suite='name.space.tests.test_suite',
- use_2to3=True,
- )
- dist = Distribution(params)
- dist.script_name = 'setup.py'
- cmd = test(dist)
- cmd.user = 1
- cmd.ensure_finalized()
- cmd.install_dir = site.USER_SITE
- cmd.user = 1
- with contexts.quiet():
- # The test runner calls sys.exit
- with contexts.suppress_exceptions(SystemExit):
- cmd.run()
+@pytest.fixture
+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', 'quiet_log')
+def test_test(capfd):
+ params = dict(
+ name='foo',
+ packages=['name', 'name.space', 'name.space.tests'],
+ namespace_packages=['name'],
+ test_suite='name.space.tests.test_suite',
+ use_2to3=True,
+ )
+ 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'
+
+
+@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'