Skip to content

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

Closed
@cjwatson

Description

@cjwatson

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   - 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions