diff --git a/newrelic/common/package_version_utils.py b/newrelic/common/package_version_utils.py index 996121756..278e51368 100644 --- a/newrelic/common/package_version_utils.py +++ b/newrelic/common/package_version_utils.py @@ -79,8 +79,6 @@ def _get_package_version(name): try: version = getattr(module, attr, None) - # In certain cases like importlib_metadata.version, version is a callable - # function. # Some frameworks (such as `pypdfium2`) may use a class # property to define the version. Because class properties # are not callable we need to check if the result is diff --git a/tests/agent_unittests/test_package_version_utils.py b/tests/agent_unittests/test_package_version_utils.py index ad02b9ed3..6394ef506 100644 --- a/tests/agent_unittests/test_package_version_utils.py +++ b/tests/agent_unittests/test_package_version_utils.py @@ -152,7 +152,6 @@ def test_version_caching(monkeypatch): assert version not in NULL_VERSIONS, version -@SKIP_IF_NOT_IMPORTLIB_METADATA def test_version_as_class_property(monkeypatch): # There is no file/module here, so we monkeypatch # pytest instead for our purposes @@ -162,18 +161,14 @@ def version(self): return "1.2.3" monkeypatch.setattr(pytest, "version", FakeModule.version, raising=False) - monkeypatch.setattr( - sys.modules["importlib"].metadata, "version", lambda x: "1.2.3", raising=False # pylint: disable=E1101 - ) version = get_package_version("pytest") - assert version == "1.2.3" + assert version not in NULL_VERSIONS, version # This test checks to see if the version is a property of the class # but also checks to see if the something like version.version_tuple # has been exported as a tuple. -@SKIP_IF_NOT_IMPORTLIB_METADATA def test_version_as_class_property_and_version_tuple(monkeypatch): # There is no file/module here, so we monkeypatch # pytest instead for our purposes @@ -184,9 +179,6 @@ def version(self): monkeypatch.setattr(pytest, "version", FakeModule.version, raising=False) monkeypatch.setattr(pytest, "version_tuple", (1, 2, 3), raising=False) - monkeypatch.setattr( - sys.modules["importlib"].metadata, "version", lambda x: "1.2.3", raising=False # pylint: disable=E1101 - ) version = get_package_version("pytest") - assert version == "1.2.3" + assert version not in NULL_VERSIONS, version