summaryrefslogtreecommitdiff
path: root/test_six.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_six.py')
-rw-r--r--test_six.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/test_six.py b/test_six.py
index 91dfdf3..13aa6ff 100644
--- a/test_six.py
+++ b/test_six.py
@@ -396,9 +396,9 @@ if six.PY3:
def test_u():
- s = six.u("hi")
+ s = six.u("hi \u0439 \U00000439 \\ \\\\ \n")
assert isinstance(s, str)
- assert s == "hi"
+ assert s == "hi \u0439 \U00000439 \\ \\\\ \n"
else:
@@ -410,9 +410,9 @@ else:
def test_u():
- s = six.u("hi")
+ s = six.u("hi \u0439 \U00000439 \\ \\\\ \n")
assert isinstance(s, unicode)
- assert s == "hi"
+ assert s == "hi \xd0\xb9 \xd0\xb9 \\ \\\\ \n".decode("utf8")
def test_u_escapes():
@@ -632,7 +632,7 @@ def test_add_metaclass():
assert instance.b == Base.b
assert instance.x == X.x
- # test a class with slots
+ # Test a class with slots.
class MySlots(object):
__slots__ = ["a", "b"]
MySlots = six.add_metaclass(Meta1)(MySlots)
@@ -641,3 +641,14 @@ def test_add_metaclass():
instance = MySlots()
instance.a = "foo"
py.test.raises(AttributeError, setattr, instance, "c", "baz")
+
+ # Test a class with string for slots.
+ class MyStringSlots(object):
+ __slots__ = "ab"
+ MyStringSlots = six.add_metaclass(Meta1)(MyStringSlots)
+ assert MyStringSlots.__slots__ == "ab"
+ instance = MyStringSlots()
+ instance.ab = "foo"
+ py.test.raises(AttributeError, setattr, instance, "a", "baz")
+ py.test.raises(AttributeError, setattr, instance, "b", "baz")
+