[4.6] fixes for python4
This commit is contained in:
parent
117f52dcf3
commit
aa79b1c00c
|
@ -0,0 +1 @@
|
||||||
|
Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing.
|
|
@ -79,7 +79,7 @@ def create_new_paste(contents):
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
"code": contents,
|
"code": contents,
|
||||||
"lexer": "python3" if sys.version_info[0] == 3 else "python",
|
"lexer": "python3" if sys.version_info[0] >= 3 else "python",
|
||||||
"expiry": "1week",
|
"expiry": "1week",
|
||||||
}
|
}
|
||||||
url = "https://bpaste.net"
|
url = "https://bpaste.net"
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ class Testdir(object):
|
||||||
|
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
ret = popen.wait()
|
ret = popen.wait()
|
||||||
elif six.PY3:
|
elif not six.PY2:
|
||||||
try:
|
try:
|
||||||
ret = popen.wait(timeout)
|
ret = popen.wait(timeout)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
|
|
|
@ -223,7 +223,7 @@ class TestGeneralUsage(object):
|
||||||
"conftest.py:2: in foo",
|
"conftest.py:2: in foo",
|
||||||
" import qwerty",
|
" import qwerty",
|
||||||
"E {}: No module named {q}qwerty{q}".format(
|
"E {}: No module named {q}qwerty{q}".format(
|
||||||
exc_name, q="'" if six.PY3 else ""
|
exc_name, q="" if six.PY2 else "'"
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -289,7 +289,7 @@ class TestUnicodeHandling:
|
||||||
|
|
||||||
success = dummy_context_manager
|
success = dummy_context_manager
|
||||||
py2_only = pytest.mark.skipif(
|
py2_only = pytest.mark.skipif(
|
||||||
six.PY3, reason="bytes in raises only supported in Python 2"
|
not six.PY2, reason="bytes in raises only supported in Python 2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
|
@ -209,7 +209,7 @@ class TestEnvironWarnings(object):
|
||||||
|
|
||||||
VAR_NAME = u"PYTEST_INTERNAL_MY_VAR"
|
VAR_NAME = u"PYTEST_INTERNAL_MY_VAR"
|
||||||
|
|
||||||
@pytest.mark.skipif(six.PY3, reason="Python 2 only test")
|
@pytest.mark.skipif(not six.PY2, reason="Python 2 only test")
|
||||||
def test_setenv_unicode_key(self, monkeypatch):
|
def test_setenv_unicode_key(self, monkeypatch):
|
||||||
with pytest.warns(
|
with pytest.warns(
|
||||||
pytest.PytestWarning,
|
pytest.PytestWarning,
|
||||||
|
@ -217,7 +217,7 @@ class TestEnvironWarnings(object):
|
||||||
):
|
):
|
||||||
monkeypatch.setenv(self.VAR_NAME, "2")
|
monkeypatch.setenv(self.VAR_NAME, "2")
|
||||||
|
|
||||||
@pytest.mark.skipif(six.PY3, reason="Python 2 only test")
|
@pytest.mark.skipif(not six.PY2, reason="Python 2 only test")
|
||||||
def test_delenv_unicode_key(self, monkeypatch):
|
def test_delenv_unicode_key(self, monkeypatch):
|
||||||
with pytest.warns(
|
with pytest.warns(
|
||||||
pytest.PytestWarning,
|
pytest.PytestWarning,
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TestPasteCapture(object):
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result = testdir.runpytest("--pastebin=all")
|
result = testdir.runpytest("--pastebin=all")
|
||||||
if sys.version_info[0] == 3:
|
if sys.version_info[0] >= 3:
|
||||||
expected_msg = "*assert '☺' == 1*"
|
expected_msg = "*assert '☺' == 1*"
|
||||||
else:
|
else:
|
||||||
expected_msg = "*assert '\\xe2\\x98\\xba' == 1*"
|
expected_msg = "*assert '\\xe2\\x98\\xba' == 1*"
|
||||||
|
@ -126,7 +126,7 @@ class TestPaste(object):
|
||||||
assert len(mocked_urlopen) == 1
|
assert len(mocked_urlopen) == 1
|
||||||
url, data = mocked_urlopen[0]
|
url, data = mocked_urlopen[0]
|
||||||
assert type(data) is bytes
|
assert type(data) is bytes
|
||||||
lexer = "python3" if sys.version_info[0] == 3 else "python"
|
lexer = "python3" if sys.version_info[0] >= 3 else "python"
|
||||||
assert url == "https://bpaste.net"
|
assert url == "https://bpaste.net"
|
||||||
assert "lexer=%s" % lexer in data.decode()
|
assert "lexer=%s" % lexer in data.decode()
|
||||||
assert "code=full-paste-contents" in data.decode()
|
assert "code=full-paste-contents" in data.decode()
|
||||||
|
|
|
@ -569,7 +569,7 @@ class TestDeprecationWarningsByDefault:
|
||||||
assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
|
assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(six.PY3, reason="Python 2 only issue")
|
@pytest.mark.skipif(not six.PY2, reason="Python 2 only issue")
|
||||||
def test_infinite_loop_warning_against_unicode_usage_py2(testdir):
|
def test_infinite_loop_warning_against_unicode_usage_py2(testdir):
|
||||||
"""
|
"""
|
||||||
We need to be careful when raising the warning about unicode usage with "warnings.warn"
|
We need to be careful when raising the warning about unicode usage with "warnings.warn"
|
||||||
|
|
Loading…
Reference in New Issue