summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2022-12-23 20:17:24 (GMT)
committerGitHub <noreply@github.com>2022-12-23 20:17:24 (GMT)
commit745545b5bb847023f90505bf9caa983463413780 (patch)
tree1b6db7fc6c92542ac9bc56769524ee26ce9eb10e /Lib/test
parentc5726b727e26b81a267933654cf26b760a90d9aa (diff)
downloadcpython-745545b5bb847023f90505bf9caa983463413780.zip
cpython-745545b5bb847023f90505bf9caa983463413780.tar.gz
cpython-745545b5bb847023f90505bf9caa983463413780.tar.bz2
gh-99482: remove `jython` compatibility parts from stdlib and tests (#99484)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/support/__init__.py3
-rw-r--r--Lib/test/support/os_helper.py6
-rw-r--r--Lib/test/test___all__.py7
-rw-r--r--Lib/test/test_codeop.py49
-rw-r--r--Lib/test/test_exceptions.py7
-rw-r--r--Lib/test/test_import/__init__.py7
-rw-r--r--Lib/test/test_platform.py2
-rw-r--r--Lib/test/test_strftime.py12
-rw-r--r--Lib/test/test_unicode.py200
9 files changed, 120 insertions, 173 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index b718605..ff736f1 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -505,6 +505,7 @@ def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
requires_legacy_unicode_capi = unittest.skipUnless(unicode_legacy_string,
'requires legacy Unicode C API')
+# Is not actually used in tests, but is kept for compatibility.
is_jython = sys.platform.startswith('java')
is_android = hasattr(sys, 'getandroidapilevel')
@@ -736,8 +737,6 @@ def gc_collect():
"""
import gc
gc.collect()
- if is_jython:
- time.sleep(0.1)
gc.collect()
gc.collect()
diff --git a/Lib/test/support/os_helper.py b/Lib/test/support/os_helper.py
index f37a442..2d4356a 100644
--- a/Lib/test/support/os_helper.py
+++ b/Lib/test/support/os_helper.py
@@ -11,11 +11,7 @@ import warnings
# Filename used for testing
-if os.name == 'java':
- # Jython disallows @ in module names
- TESTFN_ASCII = '$test'
-else:
- TESTFN_ASCII = '@test'
+TESTFN_ASCII = '@test'
# Disambiguate TESTFN for parallel testing, while letting it remain a valid
# module name.
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 1ec83cb..ecf73b3 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -100,10 +100,9 @@ class AllTest(unittest.TestCase):
'__future__',
])
- if not sys.platform.startswith('java'):
- # In case _socket fails to build, make this test fail more gracefully
- # than an AttributeError somewhere deep in CGIHTTPServer.
- import _socket
+ # In case _socket fails to build, make this test fail more gracefully
+ # than an AttributeError somewhere deep in CGIHTTPServer.
+ import _socket
ignored = []
failed_imports = []
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index d7b51be..6966c2f 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -2,47 +2,18 @@
Test cases for codeop.py
Nick Mathewson
"""
-import sys
import unittest
import warnings
-from test import support
from test.support import warnings_helper
from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT
-import io
-
-if support.is_jython:
-
- def unify_callables(d):
- for n,v in d.items():
- if hasattr(v, '__call__'):
- d[n] = True
- return d
class CodeopTests(unittest.TestCase):
def assertValid(self, str, symbol='single'):
'''succeed iff str is a valid piece of code'''
- if support.is_jython:
- code = compile_command(str, "<input>", symbol)
- self.assertTrue(code)
- if symbol == "single":
- d,r = {},{}
- saved_stdout = sys.stdout
- sys.stdout = io.StringIO()
- try:
- exec(code, d)
- exec(compile(str,"<input>","single"), r)
- finally:
- sys.stdout = saved_stdout
- elif symbol == 'eval':
- ctx = {'a': 2}
- d = { 'value': eval(code,ctx) }
- r = { 'value': eval(str,ctx) }
- self.assertEqual(unify_callables(r),unify_callables(d))
- else:
- expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
- self.assertEqual(compile_command(str, "<input>", symbol), expected)
+ expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
+ self.assertEqual(compile_command(str, "<input>", symbol), expected)
def assertIncomplete(self, str, symbol='single'):
'''succeed iff str is the start of a valid piece of code'''
@@ -62,16 +33,12 @@ class CodeopTests(unittest.TestCase):
av = self.assertValid
# special case
- if not support.is_jython:
- self.assertEqual(compile_command(""),
- compile("pass", "<input>", 'single',
- PyCF_DONT_IMPLY_DEDENT))
- self.assertEqual(compile_command("\n"),
- compile("pass", "<input>", 'single',
- PyCF_DONT_IMPLY_DEDENT))
- else:
- av("")
- av("\n")
+ self.assertEqual(compile_command(""),
+ compile("pass", "<input>", 'single',
+ PyCF_DONT_IMPLY_DEDENT))
+ self.assertEqual(compile_command("\n"),
+ compile("pass", "<input>", 'single',
+ PyCF_DONT_IMPLY_DEDENT))
av("a = 1")
av("\na = 1")
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 65a3a8a..f629321 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -360,10 +360,9 @@ class ExceptionTests(unittest.TestCase):
self.assertRaises(SystemError, _testcapi.raise_exception,
InvalidException, 1)
- if not sys.platform.startswith('java'):
- test_capi1()
- test_capi2()
- test_capi3()
+ test_capi1()
+ test_capi2()
+ test_capi3()
def test_WindowsError(self):
try:
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index 6c5b80b..1e4429e 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -20,7 +20,7 @@ from unittest import mock
from test.support import os_helper
from test.support import (
- STDLIB_DIR, is_jython, swap_attr, swap_item, cpython_only, is_emscripten,
+ STDLIB_DIR, swap_attr, swap_item, cpython_only, is_emscripten,
is_wasi)
from test.support.import_helper import (
forget, make_legacy_pyc, unlink, unload, DirsOnSysPath, CleanImport)
@@ -163,10 +163,7 @@ class ImportTests(unittest.TestCase):
def test_with_extension(ext):
# The extension is normally ".py", perhaps ".pyw".
source = TESTFN + ext
- if is_jython:
- pyc = TESTFN + "$py.class"
- else:
- pyc = TESTFN + ".pyc"
+ pyc = TESTFN + ".pyc"
with open(source, "w", encoding='utf-8') as f:
print("# This tests Python's ability to import a",
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 3992faf..72942dd 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -329,7 +329,7 @@ class PlatformTest(unittest.TestCase):
def test_java_ver(self):
res = platform.java_ver()
- if sys.platform == 'java':
+ if sys.platform == 'java': # Is never actually checked in CI
self.assertTrue(all(res))
def test_win32_ver(self):
diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index be43c49..cebfc89 100644
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -54,14 +54,10 @@ class StrftimeTest(unittest.TestCase):
self.now = now
def setUp(self):
- try:
- import java
- java.util.Locale.setDefault(java.util.Locale.US)
- except ImportError:
- from locale import setlocale, LC_TIME
- saved_locale = setlocale(LC_TIME)
- setlocale(LC_TIME, 'C')
- self.addCleanup(setlocale, LC_TIME, saved_locale)
+ from locale import setlocale, LC_TIME
+ saved_locale = setlocale(LC_TIME)
+ setlocale(LC_TIME, 'C')
+ self.addCleanup(setlocale, LC_TIME, saved_locale)
def test_strftime(self):
now = time.time()
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 5465d35..79360f5 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -94,88 +94,86 @@ class UnicodeTest(string_tests.CommonTest,
self.assertNotEqual(r"\u0020", " ")
def test_ascii(self):
- if not sys.platform.startswith('java'):
- # Test basic sanity of repr()
- self.assertEqual(ascii('abc'), "'abc'")
- self.assertEqual(ascii('ab\\c'), "'ab\\\\c'")
- self.assertEqual(ascii('ab\\'), "'ab\\\\'")
- self.assertEqual(ascii('\\c'), "'\\\\c'")
- self.assertEqual(ascii('\\'), "'\\\\'")
- self.assertEqual(ascii('\n'), "'\\n'")
- self.assertEqual(ascii('\r'), "'\\r'")
- self.assertEqual(ascii('\t'), "'\\t'")
- self.assertEqual(ascii('\b'), "'\\x08'")
- self.assertEqual(ascii("'\""), """'\\'"'""")
- self.assertEqual(ascii("'\""), """'\\'"'""")
- self.assertEqual(ascii("'"), '''"'"''')
- self.assertEqual(ascii('"'), """'"'""")
- latin1repr = (
- "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
- "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
- "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI"
- "JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f"
- "\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d"
- "\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b"
- "\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9"
- "\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7"
- "\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5"
- "\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3"
- "\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1"
- "\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef"
- "\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd"
- "\\xfe\\xff'")
- testrepr = ascii(''.join(map(chr, range(256))))
- self.assertEqual(testrepr, latin1repr)
- # Test ascii works on wide unicode escapes without overflow.
- self.assertEqual(ascii("\U00010000" * 39 + "\uffff" * 4096),
- ascii("\U00010000" * 39 + "\uffff" * 4096))
-
- class WrongRepr:
- def __repr__(self):
- return b'byte-repr'
- self.assertRaises(TypeError, ascii, WrongRepr())
+ # Test basic sanity of repr()
+ self.assertEqual(ascii('abc'), "'abc'")
+ self.assertEqual(ascii('ab\\c'), "'ab\\\\c'")
+ self.assertEqual(ascii('ab\\'), "'ab\\\\'")
+ self.assertEqual(ascii('\\c'), "'\\\\c'")
+ self.assertEqual(ascii('\\'), "'\\\\'")
+ self.assertEqual(ascii('\n'), "'\\n'")
+ self.assertEqual(ascii('\r'), "'\\r'")
+ self.assertEqual(ascii('\t'), "'\\t'")
+ self.assertEqual(ascii('\b'), "'\\x08'")
+ self.assertEqual(ascii("'\""), """'\\'"'""")
+ self.assertEqual(ascii("'\""), """'\\'"'""")
+ self.assertEqual(ascii("'"), '''"'"''')
+ self.assertEqual(ascii('"'), """'"'""")
+ latin1repr = (
+ "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
+ "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
+ "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI"
+ "JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f"
+ "\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d"
+ "\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b"
+ "\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9"
+ "\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7"
+ "\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5"
+ "\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3"
+ "\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1"
+ "\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef"
+ "\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd"
+ "\\xfe\\xff'")
+ testrepr = ascii(''.join(map(chr, range(256))))
+ self.assertEqual(testrepr, latin1repr)
+ # Test ascii works on wide unicode escapes without overflow.
+ self.assertEqual(ascii("\U00010000" * 39 + "\uffff" * 4096),
+ ascii("\U00010000" * 39 + "\uffff" * 4096))
+
+ class WrongRepr:
+ def __repr__(self):
+ return b'byte-repr'
+ self.assertRaises(TypeError, ascii, WrongRepr())
def test_repr(self):
- if not sys.platform.startswith('java'):
- # Test basic sanity of repr()
- self.assertEqual(repr('abc'), "'abc'")
- self.assertEqual(repr('ab\\c'), "'ab\\\\c'")
- self.assertEqual(repr('ab\\'), "'ab\\\\'")
- self.assertEqual(repr('\\c'), "'\\\\c'")
- self.assertEqual(repr('\\'), "'\\\\'")
- self.assertEqual(repr('\n'), "'\\n'")
- self.assertEqual(repr('\r'), "'\\r'")
- self.assertEqual(repr('\t'), "'\\t'")
- self.assertEqual(repr('\b'), "'\\x08'")
- self.assertEqual(repr("'\""), """'\\'"'""")
- self.assertEqual(repr("'\""), """'\\'"'""")
- self.assertEqual(repr("'"), '''"'"''')
- self.assertEqual(repr('"'), """'"'""")
- latin1repr = (
- "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
- "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
- "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI"
- "JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f"
- "\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d"
- "\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b"
- "\\x9c\\x9d\\x9e\\x9f\\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9"
- "\xaa\xab\xac\\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
- "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5"
- "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3"
- "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1"
- "\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
- "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd"
- "\xfe\xff'")
- testrepr = repr(''.join(map(chr, range(256))))
- self.assertEqual(testrepr, latin1repr)
- # Test repr works on wide unicode escapes without overflow.
- self.assertEqual(repr("\U00010000" * 39 + "\uffff" * 4096),
- repr("\U00010000" * 39 + "\uffff" * 4096))
-
- class WrongRepr:
- def __repr__(self):
- return b'byte-repr'
- self.assertRaises(TypeError, repr, WrongRepr())
+ # Test basic sanity of repr()
+ self.assertEqual(repr('abc'), "'abc'")
+ self.assertEqual(repr('ab\\c'), "'ab\\\\c'")
+ self.assertEqual(repr('ab\\'), "'ab\\\\'")
+ self.assertEqual(repr('\\c'), "'\\\\c'")
+ self.assertEqual(repr('\\'), "'\\\\'")
+ self.assertEqual(repr('\n'), "'\\n'")
+ self.assertEqual(repr('\r'), "'\\r'")
+ self.assertEqual(repr('\t'), "'\\t'")
+ self.assertEqual(repr('\b'), "'\\x08'")
+ self.assertEqual(repr("'\""), """'\\'"'""")
+ self.assertEqual(repr("'\""), """'\\'"'""")
+ self.assertEqual(repr("'"), '''"'"''')
+ self.assertEqual(repr('"'), """'"'""")
+ latin1repr = (
+ "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
+ "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
+ "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI"
+ "JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f"
+ "\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d"
+ "\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b"
+ "\\x9c\\x9d\\x9e\\x9f\\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9"
+ "\xaa\xab\xac\\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5"
+ "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3"
+ "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1"
+ "\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd"
+ "\xfe\xff'")
+ testrepr = repr(''.join(map(chr, range(256))))
+ self.assertEqual(testrepr, latin1repr)
+ # Test repr works on wide unicode escapes without overflow.
+ self.assertEqual(repr("\U00010000" * 39 + "\uffff" * 4096),
+ repr("\U00010000" * 39 + "\uffff" * 4096))
+
+ class WrongRepr:
+ def __repr__(self):
+ return b'byte-repr'
+ self.assertRaises(TypeError, repr, WrongRepr())
def test_iterators(self):
# Make sure unicode objects have an __iter__ method
@@ -684,8 +682,7 @@ class UnicodeTest(string_tests.CommonTest,
def test_isupper(self):
super().test_isupper()
- if not sys.platform.startswith('java'):
- self.checkequalnofix(False, '\u1FFc', 'isupper')
+ self.checkequalnofix(False, '\u1FFc', 'isupper')
self.assertTrue('\u2167'.isupper())
self.assertFalse('\u2177'.isupper())
# non-BMP, uppercase
@@ -1473,10 +1470,9 @@ class UnicodeTest(string_tests.CommonTest,
self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 3.5), 'abc, abc, -1, -2.000000, 3.50')
self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 3.57), 'abc, abc, -1, -2.000000, 3.57')
self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 1003.57), 'abc, abc, -1, -2.000000, 1003.57')
- if not sys.platform.startswith('java'):
- self.assertEqual("%r, %r" % (b"abc", "abc"), "b'abc', 'abc'")
- self.assertEqual("%r" % ("\u1234",), "'\u1234'")
- self.assertEqual("%a" % ("\u1234",), "'\\u1234'")
+ self.assertEqual("%r, %r" % (b"abc", "abc"), "b'abc', 'abc'")
+ self.assertEqual("%r" % ("\u1234",), "'\u1234'")
+ self.assertEqual("%a" % ("\u1234",), "'\\u1234'")
self.assertEqual("%(x)s, %(y)s" % {'x':"abc", 'y':"def"}, 'abc, def')
self.assertEqual("%(x)s, %(\xfc)s" % {'x':"abc", '\xfc':"def"}, 'abc, def')
@@ -1671,29 +1667,27 @@ class UnicodeTest(string_tests.CommonTest,
# unicode(obj, encoding, error) tests (this maps to
# PyUnicode_FromEncodedObject() at C level)
- if not sys.platform.startswith('java'):
- self.assertRaises(
- TypeError,
- str,
- 'decoding unicode is not supported',
- 'utf-8',
- 'strict'
- )
+ self.assertRaises(
+ TypeError,
+ str,
+ 'decoding unicode is not supported',
+ 'utf-8',
+ 'strict'
+ )
self.assertEqual(
str(b'strings are decoded to unicode', 'utf-8', 'strict'),
'strings are decoded to unicode'
)
- if not sys.platform.startswith('java'):
- self.assertEqual(
- str(
- memoryview(b'character buffers are decoded to unicode'),
- 'utf-8',
- 'strict'
- ),
- 'character buffers are decoded to unicode'
- )
+ self.assertEqual(
+ str(
+ memoryview(b'character buffers are decoded to unicode'),
+ 'utf-8',
+ 'strict'
+ ),
+ 'character buffers are decoded to unicode'
+ )
self.assertRaises(TypeError, str, 42, 42, 42)