File: tests-endian.patch

package info (click to toggle)
python-djvulibre 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 696 kB
  • sloc: python: 2,449; makefile: 38; sh: 25
file content (40 lines) | stat: -rw-r--r-- 1,592 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From: Colin Watson <cjwatson@debian.org>
Date: Mon, 28 Apr 2025 00:31:28 +0100
Subject: Fix PageJobTestCase.test_decode on big-endian systems

These parts of the test case are working with `array.array('I', ...)`
buffers, whose `tobytes()` serialization depends on the platform's byte
ordering.

Fixes: #17

Forwarded: https://github.com/FriedrichFroebel/python-djvulibre/pull/25
Bug: https://github.com/FriedrichFroebel/python-djvulibre/issues/17
Bug-Debian: https://bugs.debian.org/1103593
Last-Update: 2025-04-28
---
 tests/test_decode.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test_decode.py b/tests/test_decode.py
index e32a27f..e13eb16 100644
--- a/tests/test_decode.py
+++ b/tests/test_decode.py
@@ -525,7 +525,7 @@ class PageJobsTestCase(TestCase):
         pixel_format = PixelFormatRgbMask(0xFF0000, 0xFF00, 0xFF, bpp=32)
         self.assertIs(page_job.render(RENDER_COLOR, (0, 0, 10, 10), (0, 0, 2, 2), pixel_format, 1, buffer), buffer)
         s = buffer.tobytes()
-        self.assertEqual(s, b'\xFF\xFF\xFF\x00' * 4)
+        self.assertEqual(s, (b'\x00\xFF\xFF\xFF' if sys.byteorder == 'big' else b'\xFF\xFF\xFF\x00') * 4)
 
         if sys.version_info >= (3, 3):
             buffer = bytearray(16)
@@ -535,7 +535,7 @@ class PageJobsTestCase(TestCase):
                 memview
             )
             s = bytes(buffer)
-            self.assertEqual(s, b'\xFF\xFF\xFF\x00' * 4)
+            self.assertEqual(s, (b'\x00\xFF\xFF\xFF' if sys.byteorder == 'big' else b'\xFF\xFF\xFF\x00') * 4)
 
 
 class ThumbnailsTestCase(TestCase):