summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/builtin_ord.py6
-rw-r--r--tests/basics/bytes_construct.py12
-rw-r--r--tests/basics/setattr1.py5
-rw-r--r--tests/basics/string1.py4
-rw-r--r--tests/basics/string_compare.py5
-rw-r--r--tests/basics/string_format.py6
-rw-r--r--tests/basics/struct1.py6
7 files changed, 44 insertions, 0 deletions
diff --git a/tests/basics/builtin_ord.py b/tests/basics/builtin_ord.py
index 66e56e5c6f..1556970ee3 100644
--- a/tests/basics/builtin_ord.py
+++ b/tests/basics/builtin_ord.py
@@ -20,3 +20,9 @@ try:
ord(b'')
except TypeError:
print("TypeError")
+
+# argument must be a string
+try:
+ ord(1)
+except TypeError:
+ print('TypeError')
diff --git a/tests/basics/bytes_construct.py b/tests/basics/bytes_construct.py
index e43c8179fc..59e02f063c 100644
--- a/tests/basics/bytes_construct.py
+++ b/tests/basics/bytes_construct.py
@@ -14,6 +14,18 @@ print(bytes(array('h', [0x101, 0x202])))
# long ints
print(ord(bytes([14953042807679334000 & 0xff])))
+# constructor value out of range
+try:
+ bytes([-1])
+except ValueError:
+ print('ValueError')
+
+# constructor value out of range
+try:
+ bytes([256])
+except ValueError:
+ print('ValueError')
+
# error in construction
try:
a = bytes([1, 2, 3], 1)
diff --git a/tests/basics/setattr1.py b/tests/basics/setattr1.py
index acc3299119..9693aca819 100644
--- a/tests/basics/setattr1.py
+++ b/tests/basics/setattr1.py
@@ -11,3 +11,8 @@ setattr(a, "var", 123)
setattr(a, "var2", 56)
print(a.var)
print(a.var2)
+
+try:
+ setattr(a, b'var3', 1)
+except TypeError:
+ print('TypeError')
diff --git a/tests/basics/string1.py b/tests/basics/string1.py
index b8ca15c344..b3abfb9c60 100644
--- a/tests/basics/string1.py
+++ b/tests/basics/string1.py
@@ -24,6 +24,10 @@ try:
'123' * '1'
except TypeError:
print('TypeError')
+try:
+ '123' + 1
+except TypeError:
+ print('TypeError')
# subscription
print('abc'[1])
diff --git a/tests/basics/string_compare.py b/tests/basics/string_compare.py
index 740e1959c8..f011ed3630 100644
--- a/tests/basics/string_compare.py
+++ b/tests/basics/string_compare.py
@@ -48,3 +48,8 @@ print("1" <= "10")
print("1" <= "1/")
print("10" <= "1")
print("1/" <= "1")
+
+# this tests an internal string that doesn't have a hash with a string
+# that does have a hash, but the lengths of the two strings are different
+import sys
+print(sys.version == 'a long string that has a hash')
diff --git a/tests/basics/string_format.py b/tests/basics/string_format.py
index b0e49f530a..d8724c9474 100644
--- a/tests/basics/string_format.py
+++ b/tests/basics/string_format.py
@@ -207,3 +207,9 @@ try:
'{:*"1"}'.format('zz')
except ValueError:
print('ValueError')
+
+# unknown format code for str arg
+try:
+ '{:X}'.format('zz')
+except ValueError:
+ print('ValueError')
diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py
index 87e2f07026..686251c446 100644
--- a/tests/basics/struct1.py
+++ b/tests/basics/struct1.py
@@ -52,3 +52,9 @@ print(struct.unpack("<Q", b"\xff\xff\xff\xff\xff\xff\xff\xff"))
# network byte order
print(struct.pack('!i', 123))
+
+# first arg must be a string
+try:
+ struct.pack(1, 2)
+except TypeError:
+ print('TypeError')