Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional API tests still broken on big-endian machines #319

Open
cjwatson opened this issue Sep 13, 2024 · 0 comments
Open

Functional API tests still broken on big-endian machines #319

cjwatson opened this issue Sep 13, 2024 · 0 comments

Comments

@cjwatson
Copy link

8c274e5 tried to fix these tests on big-endian machines. However, they're still broken according to https://ci.debian.net/packages/i/importlib-resources/testing/s390x/51580020/ (that's importlib-resources 6.4.4, but it doesn't look like 6.4.5 changes anything here). Here's output from one of the tests:

________________ FunctionalAPITest_StringAnchor.test_open_text _________________

self = <importlib_resources.tests.test_functional.FunctionalAPITest_StringAnchor testMethod=test_open_text>

    def test_open_text(self):
        with resources.open_text(self.anchor01, 'utf-8.file') as f:
            self.assertEqual(f.read(), 'Hello, UTF-8 world!\n')
        for path_parts in self._gen_resourcetxt_path_parts():
            with resources.open_text(
                self.anchor02,
                *path_parts,
                encoding='utf-8',
            ) as f:
                self.assertEqual(f.read(), 'a resource')
        # Use generic OSError, since e.g. attempting to read a directory can
        # fail with PermissionError rather than IsADirectoryError
        with self.assertRaises(OSError):
            resources.open_text(self.anchor01)
        with self.assertRaises(OSError):
            resources.open_text(self.anchor01, 'no-such-file')
        with resources.open_text(self.anchor01, 'utf-16.file') as f:
            with self.assertRaises(UnicodeDecodeError):
                f.read()
        with resources.open_text(
            self.anchor01,
            'binary.file',
            encoding='latin1',
        ) as f:
            self.assertEqual(f.read(), '\x00\x01\x02\x03')
        with resources.open_text(
            self.anchor01,
            'utf-16.file',
            errors='backslashreplace',
        ) as f:
>           self.assertEndsWith(  # ignore the BOM
                f.read(),
                'Hello, UTF-16 world!\n'.encode('utf-16-le').decode(
                    errors='backslashreplace',
                ),
            )

tests/test_functional.py:144: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_functional.py:50: in assertEndsWith
    self.assertEqual(string[-len(suffix) :], suffix)
E   AssertionError: '\x00H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\[61 chars]00\n' != 'H\x00e\x00l\x00l\x00o\x00,\x00 \x00U\x00T[61 chars]\x00'
E   - E   ? -
E   + HE   - 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant