Skip to content

Compatibility of tests with Python 3.15 #530

@frenzymadness

Description

@frenzymadness

What pipdeptree version are you using?

2.30.0

Are you running pipdeptree in a virtual environment?

No

Describe the problem

When running tests with Python 3.15 during build of RPM package in Fedora, we get:

=================================== FAILURES ===================================
____________________________ test_invalid_metadata _____________________________

mocker = <pytest_mock.plugin.MockerFixture object at 0x7f18e425f450>
capfd = <_pytest.capture.CaptureFixture object at 0x7f18e4186050>
fake_dist_with_invalid_metadata = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_invalid_metadata0/site-packages/bar-2.4.5.dist-info')

    def test_invalid_metadata(
        mocker: MockerFixture, capfd: pytest.CaptureFixture[str], fake_dist_with_invalid_metadata: Path
    ) -> None:
        fake_site_dir = str(fake_dist_with_invalid_metadata.parent)
        mocked_sys_path = [fake_site_dir]
        mocker.patch("pipdeptree._discovery.sys.path", mocked_sys_path)
    
>       dists = get_installed_distributions()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_discovery.py:165: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../BUILDROOT/usr/lib/python3.15/site-packages/pipdeptree/_discovery.py:49: in get_installed_distributions
    return filter_valid_distributions(distributions(path=computed_paths))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../BUILDROOT/usr/lib/python3.15/site-packages/pipdeptree/_discovery.py:89: in filter_valid_distributions
    if not has_valid_metadata(dist):
           ^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

dist = <importlib.metadata.PathDistribution object at 0x7f18e41ec640>

    def has_valid_metadata(dist: Distribution) -> bool:
>       return "Name" in dist.metadata
               ^^^^^^^^^^^^^^^^^^^^^^^
E       TypeError: argument of type 'NoneType' is not a container or iterable

../BUILDROOT/usr/lib/python3.15/site-packages/pipdeptree/_discovery.py:119: TypeError
=========================== short test summary info ============================
FAILED tests/test_discovery.py::test_invalid_metadata - TypeError: argument of type 'NoneType' is not a container or iterable
================= 1 failed, 143 passed, 7 deselected in 1.10s ==================

Metadata

Metadata

Assignees

Labels

bugupstreamThis is an issue with pipdeptree's dependencies

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions