Skip to content

Commit

Permalink
Remove capsys_disabled() backport now that we're on pytest 3 in all envs
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Dec 24, 2017
1 parent 6e8a4f7 commit 9699f40
Showing 1 changed file with 33 additions and 50 deletions.
83 changes: 33 additions & 50 deletions versionfinder/tests/test_acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,6 @@ def _check_output(args, stderr=None, env=None):
return res


@contextmanager
def capsys_disabled(capsys):
"""
Backport of pytest's ``capsys.disabled`` ContextManager to pytest versions
< 3.0. Allows us to print/write directly to stdout and stderr from within
tests.
:param capsys: pytest capsys fixture
"""
capmanager = capsys.request.config.pluginmanager.getplugin('capturemanager')
capmanager.suspendcapture_item(capsys.request.node, "call", in_=True)
try:
yield
finally:
capmanager.resumecapture()


class AcceptanceHelpers(object):
"""
Long-running acceptance tests for VersionFinder.
Expand Down Expand Up @@ -482,7 +465,7 @@ def test_install_local_master(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._pip_install(path, [test_src])
Expand All @@ -507,7 +490,7 @@ def test_install_local_e(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._pip_install(path, ['-e', test_src])
Expand Down Expand Up @@ -536,7 +519,7 @@ def test_install_local_e_dirty(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._pip_install(path, ['-e', test_src])
Expand Down Expand Up @@ -569,7 +552,7 @@ def test_install_local_e_tag(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test(ref=TEST_TAG_COMMIT)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._pip_install(path, ['-e', test_src])
Expand Down Expand Up @@ -598,7 +581,7 @@ def test_install_local_e_checkout_tag(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._pip_install(path, ['-e', test_src])
Expand Down Expand Up @@ -628,7 +611,7 @@ def test_install_local_e_checkout_commit(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._pip_install(path, ['-e', test_src])
Expand Down Expand Up @@ -658,7 +641,7 @@ def test_install_local_e_multiple_remotes(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._git_add_remote(test_src, 'testremote',
Expand Down Expand Up @@ -690,7 +673,7 @@ def test_install_local_e_multiple_remotes(self, capsys, tmpdir):
def test_install_sdist(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_TARBALL_PATH))
self._pip_install(path, [TEST_TARBALL_PATH])
Expand Down Expand Up @@ -719,7 +702,7 @@ def test_install_sdist_pip154(self, capsys, tmpdir):
"""regression test for issue #55"""
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_TARBALL_PATH))
self._pip_install(path, ['--force-reinstall', 'pip==1.5.4'])
Expand All @@ -744,7 +727,7 @@ def test_install_sdist_pip154(self, capsys, tmpdir):
def test_install_bdist_wheel(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_WHEEL_PATH))
self._pip_install(path, [TEST_WHEEL_PATH])
Expand All @@ -770,7 +753,7 @@ def test_install_bdist_wheel_no_git_binary(self, capsys, tmpdir):
e['GIT_PYTHON_GIT_EXECUTABLE'] = '/tmp/NoSuchFile'
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_WHEEL_PATH))
self._pip_install(path, [TEST_WHEEL_PATH])
Expand All @@ -794,7 +777,7 @@ def test_install_bdist_wheel_no_git_binary(self, capsys, tmpdir):
def test_install_git(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -822,7 +805,7 @@ def test_install_git(self, capsys, tmpdir):
def test_install_git_fork(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -850,7 +833,7 @@ def test_install_git_fork(self, capsys, tmpdir):
def test_install_git_commit(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -879,7 +862,7 @@ def test_install_git_commit(self, capsys, tmpdir):
def test_install_git_tag(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -908,7 +891,7 @@ def test_install_git_tag(self, capsys, tmpdir):
def test_install_git_branch(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -937,7 +920,7 @@ def test_install_git_branch(self, capsys, tmpdir):
def test_install_git_e(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -970,7 +953,7 @@ def test_install_git_e(self, capsys, tmpdir):
def test_install_git_e_fork(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -1009,7 +992,7 @@ def test_install_git_e_fork(self, capsys, tmpdir):
def test_install_git_e_multiple_remotes(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -1046,7 +1029,7 @@ def test_install_git_e_multiple_remotes(self, capsys, tmpdir):
def test_install_git_e_dirty(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -1086,7 +1069,7 @@ def test_install_git_e_dirty(self, capsys, tmpdir):
def test_install_git_e_commit(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -1120,7 +1103,7 @@ def test_install_git_e_commit(self, capsys, tmpdir):
def test_install_git_e_tag(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -1154,7 +1137,7 @@ def test_install_git_e_tag(self, capsys, tmpdir):
def test_install_git_e_branch(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
Expand Down Expand Up @@ -1190,7 +1173,7 @@ def test_install_sdist_in_git_repo(self, capsys, tmpdir):
path = str(tmpdir)
self._make_git_repo(path)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_TARBALL_PATH))
self._pip_install(path, [TEST_TARBALL_PATH])
Expand All @@ -1216,7 +1199,7 @@ def test_install_wheel_in_git_repo(self, capsys, tmpdir):
path = str(tmpdir)
self._make_git_repo(path)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_WHEEL_PATH))
self._pip_install(path, [TEST_WHEEL_PATH])
Expand Down Expand Up @@ -1245,7 +1228,7 @@ def test_develop(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
with chdir(test_src):
Expand Down Expand Up @@ -1282,7 +1265,7 @@ def test_install(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
with chdir(test_src):
Expand Down Expand Up @@ -1319,7 +1302,7 @@ def test_install_local_master(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._easy_install(path, [test_src])
Expand All @@ -1344,7 +1327,7 @@ def test_install_sdist(self, capsys, tmpdir):
"""regression test for issue #73"""
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_TARBALL_PATH))
self._easy_install(path, [TEST_TARBALL_PATH])
Expand All @@ -1371,7 +1354,7 @@ def test_install_egg(self, capsys, tmpdir):
pytest.skip("No egg for python version")
path = str(tmpdir)
self._make_venv(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_EGG_PATH))
self._easy_install(path, [TEST_TARBALL_PATH])
Expand All @@ -1397,7 +1380,7 @@ def test_install_local_master_in_git_repo(self, capsys, tmpdir):
self._make_venv(path)
self._make_git_repo(path)
test_src = self._git_clone_test()
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, test_src))
self._easy_install(path, [test_src])
Expand All @@ -1423,7 +1406,7 @@ def test_install_sdist_in_git_repo(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
self._make_git_repo(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_TARBALL_PATH))
self._easy_install(path, [TEST_TARBALL_PATH])
Expand Down Expand Up @@ -1451,7 +1434,7 @@ def test_install_egg_in_git_repo(self, capsys, tmpdir):
path = str(tmpdir)
self._make_venv(path)
self._make_git_repo(path)
with capsys_disabled(capsys):
with capsys.disabled(capsys):
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, TEST_EGG_PATH))
self._easy_install(path, [TEST_TARBALL_PATH])
Expand Down

0 comments on commit 9699f40

Please sign in to comment.