Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions elasticapm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,16 +660,8 @@ def should_ignore_topic(self, topic: str) -> bool:

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

def check_server_version(
self, gte: Optional[Tuple[int, ...]] = None, lte: Optional[Tuple[int, ...]] = None
Expand Down
30 changes: 12 additions & 18 deletions tests/client/client_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,32 +427,26 @@ def test_server_url_joining(elasticapm_client, expected):


@pytest.mark.parametrize(
"version,raises,pending",
"version",
[
(("2", "7", "0"), True, True),
(("3", "3", "0"), True, False),
(("3", "4", "0"), True, False),
(("3", "5", "0"), False, False),
("2", "7", "0"),
("3", "3", "0"),
("3", "4", "0"),
("3", "5", "0"),
],
)
@mock.patch("platform.python_version_tuple")
def test_python_version_deprecation(mock_python_version_tuple, version, raises, pending, recwarn):
def test_python_version_deprecation(mock_python_version_tuple, version):
warnings.simplefilter("always")

mock_python_version_tuple.return_value = version
e = None
try:
e = elasticapm.Client()
finally:
if e:
e.close()
if raises:
if pending:
w = recwarn.pop(PendingDeprecationWarning)
assert "will stop supporting" in w.message.args[0]
else:
w = recwarn.pop(DeprecationWarning)
assert "agent only supports" in w.message.args[0]
with pytest.warns(DeprecationWarning, match="agent only supports"):
try:
e = elasticapm.Client()
finally:
if e:
e.close()


def test_recording(elasticapm_client):
Expand Down