From 54e88aec5f7156dd6dcd440abb5b7e81cdb38ca5 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 20 Dec 2013 22:14:45 -0600 Subject: fix add_metaclass when __slots__ is a string (fixes #47) --- test_six.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test_six.py') diff --git a/test_six.py b/test_six.py index 81b424f..7f92617 100644 --- a/test_six.py +++ b/test_six.py @@ -630,3 +630,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") + -- cgit v1.2.1