Skip to content

Commit 2af4266

Browse files
authored
Fix some deprecation warnings that were missed in the 6.0.0 release (#1729)
1 parent 7b2de88 commit 2af4266

File tree

2 files changed

+14
-28
lines changed

2 files changed

+14
-28
lines changed

elasticapm/base.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -660,16 +660,8 @@ def should_ignore_topic(self, topic: str) -> bool:
660660

661661
def check_python_version(self):
662662
v = tuple(map(int, platform.python_version_tuple()[:2]))
663-
if v == (2, 7):
664-
warnings.warn(
665-
(
666-
"The Elastic APM agent will stop supporting Python 2.7 starting in 6.0.0 -- "
667-
"Please upgrade to Python 3.5+ to continue to use the latest features."
668-
),
669-
PendingDeprecationWarning,
670-
)
671-
elif v < (3, 5):
672-
warnings.warn("The Elastic APM agent only supports Python 3.5+", DeprecationWarning)
663+
if v < (3, 6):
664+
warnings.warn("The Elastic APM agent only supports Python 3.6+", DeprecationWarning)
673665

674666
def check_server_version(
675667
self, gte: Optional[Tuple[int, ...]] = None, lte: Optional[Tuple[int, ...]] = None

tests/client/client_tests.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -427,32 +427,26 @@ def test_server_url_joining(elasticapm_client, expected):
427427

428428

429429
@pytest.mark.parametrize(
430-
"version,raises,pending",
430+
"version",
431431
[
432-
(("2", "7", "0"), True, True),
433-
(("3", "3", "0"), True, False),
434-
(("3", "4", "0"), True, False),
435-
(("3", "5", "0"), False, False),
432+
("2", "7", "0"),
433+
("3", "3", "0"),
434+
("3", "4", "0"),
435+
("3", "5", "0"),
436436
],
437437
)
438438
@mock.patch("platform.python_version_tuple")
439-
def test_python_version_deprecation(mock_python_version_tuple, version, raises, pending, recwarn):
439+
def test_python_version_deprecation(mock_python_version_tuple, version):
440440
warnings.simplefilter("always")
441441

442442
mock_python_version_tuple.return_value = version
443443
e = None
444-
try:
445-
e = elasticapm.Client()
446-
finally:
447-
if e:
448-
e.close()
449-
if raises:
450-
if pending:
451-
w = recwarn.pop(PendingDeprecationWarning)
452-
assert "will stop supporting" in w.message.args[0]
453-
else:
454-
w = recwarn.pop(DeprecationWarning)
455-
assert "agent only supports" in w.message.args[0]
444+
with pytest.warns(DeprecationWarning, match="agent only supports"):
445+
try:
446+
e = elasticapm.Client()
447+
finally:
448+
if e:
449+
e.close()
456450

457451

458452
def test_recording(elasticapm_client):

0 commit comments

Comments
 (0)