diff options
author | Benoit Pierre <benoit.pierre@gmail.com> | 2017-06-26 17:58:09 +0200 |
---|---|---|
committer | Benoit Pierre <benoit.pierre@gmail.com> | 2017-11-02 20:44:47 +0100 |
commit | b5d00314293e400bc72f3699e428f168ac74d824 (patch) | |
tree | a56ece5948c3f77125311e6af6e76e3ab669b880 /setuptools/tests/test_test.py | |
parent | dbff2e7ed421be9ec96029366479a8627691e7f3 (diff) | |
download | external_python_setuptools-b5d00314293e400bc72f3699e428f168ac74d824.tar.gz external_python_setuptools-b5d00314293e400bc72f3699e428f168ac74d824.tar.bz2 external_python_setuptools-b5d00314293e400bc72f3699e428f168ac74d824.zip |
tests: improve `test` command test
- cleanup test: we're not installing, so no need to override the user site,
or skip the test when run with a virtual environment
- use pytest support for capturing output (`context.quiet` does not work
with Python 2), and check the output
Diffstat (limited to 'setuptools/tests/test_test.py')
-rw-r--r-- | setuptools/tests/test_test.py | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 7ea43c57..02cba00d 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -2,9 +2,8 @@ from __future__ import unicode_literals +from distutils import log import os -import site -from distutils.errors import DistutilsError import pytest @@ -66,26 +65,28 @@ 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 silent_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') +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' |