Skip to content

Test failures in test_resources on Windows #591

@jaraco

Description

@jaraco

Running the tests on Windows, I see these two failures, apparently related to the case normalization:

_____________________ TestNamespaces.test_two_levels_deep _____________________

self = <pkg_resources.tests.test_resources.TestNamespaces object at 0x000001B5938F1240>
symlinked_tmpdir = local('C:\\Users\\jaraco\\AppData\\Local\\Temp\\pytest-of-jaraco\\pytest-1\\test_two_levels_deep0-lin
ked')

    def test_two_levels_deep(self, symlinked_tmpdir):
        """
            Test nested namespace packages
            Create namespace packages in the following tree :
                site-packages-1/pkg1/pkg2
                site-packages-2/pkg1/pkg2
            Check both are in the _namespace_packages dict and that their __path__
            is correct
            """
        real_tmpdir = symlinked_tmpdir.realpath()
        tmpdir = symlinked_tmpdir
        sys.path.append(str(tmpdir / 'site-pkgs2'))
        site_dirs = tmpdir / 'site-pkgs', tmpdir / 'site-pkgs2'
        for site in site_dirs:
            pkg1 = site / 'pkg1'
            pkg2 = pkg1 / 'pkg2'
            pkg2.ensure_dir()
            (pkg1 / '__init__.py').write_text(self.ns_str, encoding='utf-8')
            (pkg2 / '__init__.py').write_text(self.ns_str, encoding='utf-8')
        import pkg1
        assert "pkg1" in pkg_resources._namespace_packages
        # attempt to import pkg2 from site-pkgs2
        import pkg1.pkg2
        # check the _namespace_packages dict
        assert "pkg1.pkg2" in pkg_resources._namespace_packages
        assert pkg_resources._namespace_packages["pkg1"] == ["pkg1.pkg2"]
        # check the __path__ attribute contains both paths
        expected = [
            str(real_tmpdir / "site-pkgs" / "pkg1" / "pkg2"),
            str(real_tmpdir / "site-pkgs2" / "pkg1" / "pkg2"),
        ]
>       assert pkg1.pkg2.__path__ == expected
E       assert ['c:\\users\\...\\pkg1\\pkg2'] == ['C:\\Users\\j...\\pkg1\\pkg2']
E         At index 0 diff: 'c:\\users\\jaraco\\appdata\\local\\temp\\pytest-of-jaraco\\pytest-1\\test_two_levels_deep0\\
site-pkgs\\pkg1\\pkg2' != 'C:\\Users\\jaraco\\AppData\\Local\\Temp\\pytest-of-jaraco\\pytest-1\\test_two_levels_deep0-li
nked\\site-pkgs\\pkg1\\pkg2'
E         Use -v to get the full diff

pkg_resources\tests\test_resources.py:797: AssertionError
_______________________ TestNamespaces.test_path_order ________________________

self = <pkg_resources.tests.test_resources.TestNamespaces object at 0x000001B593919DD8>
symlinked_tmpdir = local('C:\\Users\\jaraco\\AppData\\Local\\Temp\\pytest-of-jaraco\\pytest-1\\test_path_order0-linked')

    def test_path_order(self, symlinked_tmpdir):
        """
            Test that if multiple versions of the same namespace package subpackage
            are on different sys.path entries, that only the one earliest on
            sys.path is imported, and that the namespace package's __path__ is in
            the correct order.

            Regression test for https://github.com/pypa/setuptools/issues/207
            """

        tmpdir = symlinked_tmpdir
        site_dirs = (
            tmpdir / "site-pkgs",
            tmpdir / "site-pkgs2",
            tmpdir / "site-pkgs3",
        )

        vers_str = "__version__ = %r"

        for number, site in enumerate(site_dirs, 1):
            if number > 1:
                sys.path.append(str(site))
            nspkg = site / 'nspkg'
            subpkg = nspkg / 'subpkg'
            subpkg.ensure_dir()
            (nspkg / '__init__.py').write_text(self.ns_str, encoding='utf-8')
            (subpkg / '__init__.py').write_text(vers_str % number, encoding='utf-8')

        import nspkg.subpkg
        import nspkg
        expected = [
            str(site.realpath() / 'nspkg')
            for site in site_dirs
        ]
>       assert nspkg.__path__ == expected
E       assert ['c:\\users\\...pkgs3\\nspkg'] == ['C:\\Users\\j...pkgs3\\nspkg']
E         At index 0 diff: 'c:\\users\\jaraco\\appdata\\local\\temp\\pytest-of-jaraco\\pytest-1\\test_path_order0\\site-
pkgs\\nspkg' != 'C:\\Users\\jaraco\\AppData\\Local\\Temp\\pytest-of-jaraco\\pytest-1\\test_path_order0-linked\\site-pkgs
\\nspkg'
E         Use -v to get the full diff

pkg_resources\tests\test_resources.py:833: AssertionError

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions