Skip to content

Commit 373abb3

Browse files
BCSharpslozier
authored andcommitted
Test codecs linux (#701)
* Make test_codecs passing with CPython 3.4 on Linux * Make test_codecs passing with CPython 3.4 on macOS * Revert "Make test_codecs passing with CPython 3.4 on macOS" This reverts commit e6a5391. * Use is_linux iso is_posix for Linux-specific condition in test_codecs
1 parent d3c3de3 commit 373abb3

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

Tests/modules/io_related/test_codecs.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
import sys
2222
import unittest
2323

24-
from iptest import IronPythonTestCase, is_cli, is_cpython, is_mono, is_netcoreapp, is_posix, run_test, skipUnlessIronPython
24+
from iptest import IronPythonTestCase, is_cli, is_cpython, is_mono, is_netcoreapp, is_posix, is_linux, is_windows, run_test, skipUnlessIronPython
2525
from iptest.misc_util import ip_supported_encodings
2626

27+
if is_cpython and is_linux:
28+
import time
29+
2730
class CodecTest(IronPythonTestCase):
2831
def test_escape_decode(self):
2932
# escape_decode decodes bytes to bytes, but when given a string it encodes it first with UTF-8
@@ -529,13 +532,19 @@ def test_unicode_internal_encode(self):
529532
# takes one or two parameters, not zero or three
530533
self.assertRaises(TypeError, codecs.unicode_internal_encode)
531534
self.assertRaises(TypeError, codecs.unicode_internal_encode, 'abc', 'def', 'qrt')
532-
self.assertEqual(codecs.unicode_internal_encode('abc'), (b'a\x00b\x00c\x00', 3))
535+
if is_cli or is_windows:
536+
self.assertEqual(codecs.unicode_internal_encode('abc'), (b'a\x00b\x00c\x00', 3))
537+
else:
538+
self.assertEqual(codecs.unicode_internal_encode('abc'), (b'a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00', 3))
533539

534540
def test_unicode_internal_decode(self):
535541
# takes one or two parameters, not zero or three
536542
self.assertRaises(TypeError, codecs.unicode_internal_decode)
537543
self.assertRaises(TypeError, codecs.unicode_internal_decode, 'abc', 'def', 'qrt')
538-
self.assertEqual(codecs.unicode_internal_decode(b'ab'), ('\u6261', 2))
544+
if is_cli or is_windows:
545+
self.assertEqual(codecs.unicode_internal_decode(b'ab'), ('\u6261', 2))
546+
else:
547+
self.assertEqual(codecs.unicode_internal_decode(b'ab\0\0'), ('\u6261', 4))
539548

540549
def test_utf_16_be_decode(self):
541550
string, num_processed = codecs.utf_16_be_decode(b'\0a\0b\0c')
@@ -949,6 +958,8 @@ def test_file_encodings(self):
949958

950959
f.write("# coding: %s" % (coding))
951960

961+
if is_cpython and is_linux:
962+
time.sleep(0.01)
952963
__import__(temp_mod_name)
953964
os.remove(os.path.join(self.temporary_dir, "tmp_encodings", temp_mod_name + ".py"))
954965

0 commit comments

Comments
 (0)