Skip to content

Commit aa79b1c

Browse files
committed
[4.6] fixes for python4
1 parent 117f52d commit aa79b1c

File tree

8 files changed

+10
-9
lines changed

8 files changed

+10
-9
lines changed

changelog/5801.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing.

src/_pytest/pastebin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def create_new_paste(contents):
7979

8080
params = {
8181
"code": contents,
82-
"lexer": "python3" if sys.version_info[0] == 3 else "python",
82+
"lexer": "python3" if sys.version_info[0] >= 3 else "python",
8383
"expiry": "1week",
8484
}
8585
url = "https://bpaste.net"

src/_pytest/pytester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ def handle_timeout():
11241124

11251125
if timeout is None:
11261126
ret = popen.wait()
1127-
elif six.PY3:
1127+
elif not six.PY2:
11281128
try:
11291129
ret = popen.wait(timeout)
11301130
except subprocess.TimeoutExpired:

testing/acceptance_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def foo():
223223
"conftest.py:2: in foo",
224224
" import qwerty",
225225
"E {}: No module named {q}qwerty{q}".format(
226-
exc_name, q="'" if six.PY3 else ""
226+
exc_name, q="" if six.PY2 else "'"
227227
),
228228
]
229229
)

testing/python/raises.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class TestUnicodeHandling:
289289

290290
success = dummy_context_manager
291291
py2_only = pytest.mark.skipif(
292-
six.PY3, reason="bytes in raises only supported in Python 2"
292+
not six.PY2, reason="bytes in raises only supported in Python 2"
293293
)
294294

295295
@pytest.mark.parametrize(

testing/test_monkeypatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ class TestEnvironWarnings(object):
209209

210210
VAR_NAME = u"PYTEST_INTERNAL_MY_VAR"
211211

212-
@pytest.mark.skipif(six.PY3, reason="Python 2 only test")
212+
@pytest.mark.skipif(not six.PY2, reason="Python 2 only test")
213213
def test_setenv_unicode_key(self, monkeypatch):
214214
with pytest.warns(
215215
pytest.PytestWarning,
216216
match="Environment variable name {!r} should be str".format(self.VAR_NAME),
217217
):
218218
monkeypatch.setenv(self.VAR_NAME, "2")
219219

220-
@pytest.mark.skipif(six.PY3, reason="Python 2 only test")
220+
@pytest.mark.skipif(not six.PY2, reason="Python 2 only test")
221221
def test_delenv_unicode_key(self, monkeypatch):
222222
with pytest.warns(
223223
pytest.PytestWarning,

testing/test_pastebin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test():
7474
"""
7575
)
7676
result = testdir.runpytest("--pastebin=all")
77-
if sys.version_info[0] == 3:
77+
if sys.version_info[0] >= 3:
7878
expected_msg = "*assert '☺' == 1*"
7979
else:
8080
expected_msg = "*assert '\\xe2\\x98\\xba' == 1*"
@@ -126,7 +126,7 @@ def test_create_new_paste(self, pastebin, mocked_urlopen):
126126
assert len(mocked_urlopen) == 1
127127
url, data = mocked_urlopen[0]
128128
assert type(data) is bytes
129-
lexer = "python3" if sys.version_info[0] == 3 else "python"
129+
lexer = "python3" if sys.version_info[0] >= 3 else "python"
130130
assert url == "https://bpaste.net"
131131
assert "lexer=%s" % lexer in data.decode()
132132
assert "code=full-paste-contents" in data.decode()

testing/test_warnings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def test_hidden_by_system(self, testdir, monkeypatch):
569569
assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
570570

571571

572-
@pytest.mark.skipif(six.PY3, reason="Python 2 only issue")
572+
@pytest.mark.skipif(not six.PY2, reason="Python 2 only issue")
573573
def test_infinite_loop_warning_against_unicode_usage_py2(testdir):
574574
"""
575575
We need to be careful when raising the warning about unicode usage with "warnings.warn"

0 commit comments

Comments
 (0)