Skip to content

Commit 1fd3601

Browse files
committed
Drop support for EOL Python 3.6
1 parent b9663fe commit 1fd3601

10 files changed

+63
-83
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ template = "changelog/_template.rst"
111111
showcontent = true
112112

113113
[tool.black]
114-
target-version = ['py36']
114+
target-version = ['py37']

src/_pytest/assertion/rewrite.py

-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ def find_spec(
100100
spec is None
101101
# this is a namespace package (without `__init__.py`)
102102
# there's nothing to rewrite there
103-
# python3.6: `namespace`
104-
# python3.7+: `None`
105-
or spec.origin == "namespace"
106103
or spec.origin is None
107104
# we can only rewrite source files
108105
or not isinstance(spec.loader, importlib.machinery.SourceFileLoader)

src/_pytest/capture.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def _colorama_workaround() -> None:
6868
pass
6969

7070

71-
def _py36_windowsconsoleio_workaround(stream: TextIO) -> None:
72-
"""Workaround for Windows Unicode console handling on Python>=3.6.
71+
def _windowsconsoleio_workaround(stream: TextIO) -> None:
72+
"""Workaround for Windows Unicode console handling.
7373
7474
Python 3.6 implemented Unicode console handling for Windows. This works
7575
by reading/writing to the raw console handle using
@@ -128,7 +128,7 @@ def _reopen_stdio(f, mode):
128128
def pytest_load_initial_conftests(early_config: Config):
129129
ns = early_config.known_args_namespace
130130
if ns.capture == "fd":
131-
_py36_windowsconsoleio_workaround(sys.stdout)
131+
_windowsconsoleio_workaround(sys.stdout)
132132
_colorama_workaround()
133133
pluginmanager = early_config.pluginmanager
134134
capman = CaptureManager(ns.capture)

src/_pytest/python.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
414414
for basecls in self.obj.__mro__:
415415
dicts.append(basecls.__dict__)
416416

417-
# In each class, nodes should be definition ordered. Since Python 3.6,
417+
# In each class, nodes should be definition ordered.
418418
# __dict__ is definition ordered.
419419
seen: Set[str] = set()
420420
dict_values: List[List[Union[nodes.Item, nodes.Collector]]] = []
@@ -894,8 +894,6 @@ class InstanceDummy:
894894
pass
895895

896896

897-
# Note: module __getattr__ only works on Python>=3.7. Unfortunately
898-
# we can't provide this deprecation warning on Python 3.6.
899897
def __getattr__(name: str) -> object:
900898
if name == "Instance":
901899
warnings.warn(INSTANCE_COLLECTOR, 2)

testing/deprecated_test.py

-4
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,6 @@ def test_node_ctor_fspath_argument_is_deprecated(pytester: Pytester) -> None:
234234
)
235235

236236

237-
@pytest.mark.skipif(
238-
sys.version_info < (3, 7),
239-
reason="This deprecation can only be emitted on python>=3.7",
240-
)
241237
def test_importing_instance_is_deprecated(pytester: Pytester) -> None:
242238
with pytest.warns(
243239
pytest.PytestDeprecationWarning,

testing/test_assertrewrite.py

-3
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,6 @@ def test_read_pyc(self, tmp_path: Path) -> None:
11231123

11241124
assert _read_pyc(source, pyc) is None # no error
11251125

1126-
@pytest.mark.skipif(
1127-
sys.version_info < (3, 7), reason="Only the Python 3.7 format for simplicity"
1128-
)
11291126
def test_read_pyc_more_invalid(self, tmp_path: Path) -> None:
11301127
from _pytest.assertion.rewrite import _read_pyc
11311128

testing/test_capture.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1433,19 +1433,19 @@ def test_capattr():
14331433
not sys.platform.startswith("win"),
14341434
reason="only on windows",
14351435
)
1436-
def test_py36_windowsconsoleio_workaround_non_standard_streams() -> None:
1436+
def test_windowsconsoleio_workaround_non_standard_streams() -> None:
14371437
"""
1438-
Ensure _py36_windowsconsoleio_workaround function works with objects that
1438+
Ensure _windowsconsoleio_workaround function works with objects that
14391439
do not implement the full ``io``-based stream protocol, for example execnet channels (#2666).
14401440
"""
1441-
from _pytest.capture import _py36_windowsconsoleio_workaround
1441+
from _pytest.capture import _windowsconsoleio_workaround
14421442

14431443
class DummyStream:
14441444
def write(self, s):
14451445
pass
14461446

14471447
stream = cast(TextIO, DummyStream())
1448-
_py36_windowsconsoleio_workaround(stream)
1448+
_windowsconsoleio_workaround(stream)
14491449

14501450

14511451
def test_dontreadfrominput_has_encoding(pytester: Pytester) -> None:

testing/test_compat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_is_generator_async_gen_syntax(pytester: Pytester) -> None:
133133
pytester.makepyfile(
134134
"""
135135
from _pytest.compat import is_generator
136-
def test_is_generator_py36():
136+
def test_is_generator():
137137
async def foo():
138138
yield
139139
await foo()

testing/test_error_diffs.py

+53-60
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
See https://github.com/pytest-dev/pytest/issues/3333 for details.
55
66
"""
7-
import sys
8-
97
import pytest
108
from _pytest.pytester import Pytester
119

@@ -210,68 +208,63 @@ def test_this():
210208
""",
211209
id='Test "not in" string',
212210
),
213-
]
214-
if sys.version_info[:2] >= (3, 7):
215-
TESTCASES.extend(
216-
[
217-
pytest.param(
218-
"""
219-
from dataclasses import dataclass
211+
pytest.param(
212+
"""
213+
from dataclasses import dataclass
220214
221-
@dataclass
222-
class A:
223-
a: int
224-
b: str
215+
@dataclass
216+
class A:
217+
a: int
218+
b: str
225219
226-
def test_this():
227-
result = A(1, 'spam')
228-
expected = A(2, 'spam')
229-
assert result == expected
230-
""",
231-
"""
232-
> assert result == expected
233-
E AssertionError: assert A(a=1, b='spam') == A(a=2, b='spam')
234-
E Matching attributes:
235-
E ['b']
236-
E Differing attributes:
237-
E ['a']
238-
E Drill down into differing attribute a:
239-
E a: 1 != 2
240-
E +1
241-
E -2
242-
""",
243-
id="Compare data classes",
244-
),
245-
pytest.param(
246-
"""
247-
import attr
220+
def test_this():
221+
result = A(1, 'spam')
222+
expected = A(2, 'spam')
223+
assert result == expected
224+
""",
225+
"""
226+
> assert result == expected
227+
E AssertionError: assert A(a=1, b='spam') == A(a=2, b='spam')
228+
E Matching attributes:
229+
E ['b']
230+
E Differing attributes:
231+
E ['a']
232+
E Drill down into differing attribute a:
233+
E a: 1 != 2
234+
E +1
235+
E -2
236+
""",
237+
id="Compare data classes",
238+
),
239+
pytest.param(
240+
"""
241+
import attr
248242
249-
@attr.s(auto_attribs=True)
250-
class A:
251-
a: int
252-
b: str
243+
@attr.s(auto_attribs=True)
244+
class A:
245+
a: int
246+
b: str
253247
254-
def test_this():
255-
result = A(1, 'spam')
256-
expected = A(1, 'eggs')
257-
assert result == expected
258-
""",
259-
"""
260-
> assert result == expected
261-
E AssertionError: assert A(a=1, b='spam') == A(a=1, b='eggs')
262-
E Matching attributes:
263-
E ['a']
264-
E Differing attributes:
265-
E ['b']
266-
E Drill down into differing attribute b:
267-
E b: 'spam' != 'eggs'
268-
E - eggs
269-
E + spam
270-
""",
271-
id="Compare attrs classes",
272-
),
273-
]
274-
)
248+
def test_this():
249+
result = A(1, 'spam')
250+
expected = A(1, 'eggs')
251+
assert result == expected
252+
""",
253+
"""
254+
> assert result == expected
255+
E AssertionError: assert A(a=1, b='spam') == A(a=1, b='eggs')
256+
E Matching attributes:
257+
E ['a']
258+
E Differing attributes:
259+
E ['b']
260+
E Drill down into differing attribute b:
261+
E b: 'spam' != 'eggs'
262+
E - eggs
263+
E + spam
264+
""",
265+
id="Compare attrs classes",
266+
),
267+
]
275268

276269

277270
@pytest.mark.parametrize("code, expected", TESTCASES)

testing/test_pathlib.py

-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ def test_samefile_false_negatives(tmp_path: Path, monkeypatch: MonkeyPatch) -> N
450450

451451

452452
class TestImportLibMode:
453-
@pytest.mark.skipif(sys.version_info < (3, 7), reason="Dataclasses in Python3.7+")
454453
def test_importmode_importlib_with_dataclass(self, tmp_path: Path) -> None:
455454
"""Ensure that importlib mode works with a module containing dataclasses (#7856)."""
456455
fn = tmp_path.joinpath("_src/tests/test_dataclass.py")

0 commit comments

Comments
 (0)