aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_contains.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-08-17 18:39:25 +0000
committerMartin v. Löwis <martin@v.loewis.de>2001-08-17 18:39:25 +0000
commit339d0f720e86dc34837547c90d3003a4a68d7d46 (patch)
tree2059e5d02f490540e759800b127d50f3fcd8c2b5 /Lib/test/test_contains.py
parentf75976617bb36c892ee8a0f6a6fd3caddbd38cea (diff)
downloadcpython-339d0f720e86dc34837547c90d3003a4a68d7d46.tar.gz
cpython-339d0f720e86dc34837547c90d3003a4a68d7d46.zip
Patch #445762: Support --disable-unicode
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
Diffstat (limited to 'Lib/test/test_contains.py')
-rw-r--r--Lib/test/test_contains.py93
1 files changed, 48 insertions, 45 deletions
diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py
index 8fec4251b1e..1a9a9650762 100644
--- a/Lib/test/test_contains.py
+++ b/Lib/test/test_contains.py
@@ -1,4 +1,4 @@
-from test_support import TestFailed
+from test_support import TestFailed, have_unicode
class base_set:
@@ -63,62 +63,65 @@ try:
except TypeError:
pass
-# Test char in Unicode
-check('c' in u'abc', "'c' not in u'abc'")
-check('d' not in u'abc', "'d' in u'abc'")
+if have_unicode:
-try:
- '' in u'abc'
- check(0, "'' in u'abc' did not raise error")
-except TypeError:
- pass
+ # Test char in Unicode
-try:
- 'ab' in u'abc'
- check(0, "'ab' in u'abc' did not raise error")
-except TypeError:
- pass
+ check('c' in unicode('abc'), "'c' not in u'abc'")
+ check('d' not in unicode('abc'), "'d' in u'abc'")
-try:
- None in u'abc'
- check(0, "None in u'abc' did not raise error")
-except TypeError:
- pass
+ try:
+ '' in unicode('abc')
+ check(0, "'' in u'abc' did not raise error")
+ except TypeError:
+ pass
-# Test Unicode char in Unicode
+ try:
+ 'ab' in unicode('abc')
+ check(0, "'ab' in u'abc' did not raise error")
+ except TypeError:
+ pass
-check(u'c' in u'abc', "u'c' not in u'abc'")
-check(u'd' not in u'abc', "u'd' in u'abc'")
+ try:
+ None in unicode('abc')
+ check(0, "None in u'abc' did not raise error")
+ except TypeError:
+ pass
-try:
- u'' in u'abc'
- check(0, "u'' in u'abc' did not raise error")
-except TypeError:
- pass
+ # Test Unicode char in Unicode
-try:
- u'ab' in u'abc'
- check(0, "u'ab' in u'abc' did not raise error")
-except TypeError:
- pass
+ check(unicode('c') in unicode('abc'), "u'c' not in u'abc'")
+ check(unicode('d') not in unicode('abc'), "u'd' in u'abc'")
-# Test Unicode char in string
+ try:
+ unicode('') in unicode('abc')
+ check(0, "u'' in u'abc' did not raise error")
+ except TypeError:
+ pass
-check(u'c' in 'abc', "u'c' not in 'abc'")
-check(u'd' not in 'abc', "u'd' in 'abc'")
+ try:
+ unicode('ab') in unicode('abc')
+ check(0, "u'ab' in u'abc' did not raise error")
+ except TypeError:
+ pass
-try:
- u'' in 'abc'
- check(0, "u'' in 'abc' did not raise error")
-except TypeError:
- pass
+ # Test Unicode char in string
-try:
- u'ab' in 'abc'
- check(0, "u'ab' in 'abc' did not raise error")
-except TypeError:
- pass
+ check(unicode('c') in 'abc', "u'c' not in 'abc'")
+ check(unicode('d') not in 'abc', "u'd' in 'abc'")
+
+ try:
+ unicode('') in 'abc'
+ check(0, "u'' in 'abc' did not raise error")
+ except TypeError:
+ pass
+
+ try:
+ unicode('ab') in 'abc'
+ check(0, "u'ab' in 'abc' did not raise error")
+ except TypeError:
+ pass
# A collection of tests on builtin sequence types
a = range(10)