diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2013-07-20 02:47:21 (GMT) |
---|---|---|
committer | Ethan Furman <ethan@stoneleaf.us> | 2013-07-20 02:47:21 (GMT) |
commit | 520ad5791670e356787b947baeb6885320cb6237 (patch) | |
tree | 86df068d2684754f1ae00f27580f83a752c633ba /Lib/test | |
parent | 2aa2732eafe6ede071dd0206cab831484723483d (diff) | |
download | cpython-520ad5791670e356787b947baeb6885320cb6237.zip cpython-520ad5791670e356787b947baeb6885320cb6237.tar.gz cpython-520ad5791670e356787b947baeb6885320cb6237.tar.bz2 |
Change _names to _names_ since the latter is reserved for Enum use.
Before this change only the methods were _single_underscored_; now
the attributes are as well.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_enum.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index c947182..d0b4a1c 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -516,7 +516,7 @@ class TestEnum(unittest.TestCase): def question(self): print(42) self.assertIsNot(type(Why.question), Why) - self.assertNotIn(Why.question, Why._member_names) + self.assertNotIn(Why.question, Why._member_names_) self.assertNotIn(Why.question, Why) def test_wrong_inheritance_order(self): @@ -777,10 +777,10 @@ class TestEnum(unittest.TestCase): def __new__(cls): value = len(cls.__members__) + 1 obj = object.__new__(cls) - obj._value = value + obj._value_ = value return obj def __int__(self): - return int(self._value) + return int(self._value_) self.assertEqual( list(AutoNumber), [AutoNumber.first, AutoNumber.second, AutoNumber.third], @@ -794,10 +794,10 @@ class TestEnum(unittest.TestCase): def __new__(cls): value = len(cls.__members__) + 1 obj = object.__new__(cls) - obj._value = value + obj._value_ = value return obj def __int__(self): - return int(self._value) + return int(self._value_) class Color(AutoNumber): red = () green = () @@ -810,7 +810,7 @@ class TestEnum(unittest.TestCase): def __new__(cls): value = len(cls.__members__) + 1 obj = int.__new__(cls, value) - obj._value = value + obj._value_ = value return obj class Color(AutoNumber): red = () @@ -823,19 +823,19 @@ class TestEnum(unittest.TestCase): class OrderedEnum(Enum): def __ge__(self, other): if self.__class__ is other.__class__: - return self._value >= other._value + return self._value_ >= other._value_ return NotImplemented def __gt__(self, other): if self.__class__ is other.__class__: - return self._value > other._value + return self._value_ > other._value_ return NotImplemented def __le__(self, other): if self.__class__ is other.__class__: - return self._value <= other._value + return self._value_ <= other._value_ return NotImplemented def __lt__(self, other): if self.__class__ is other.__class__: - return self._value < other._value + return self._value_ < other._value_ return NotImplemented class Grade(OrderedEnum): A = 5 @@ -847,6 +847,7 @@ class TestEnum(unittest.TestCase): self.assertLessEqual(Grade.F, Grade.C) self.assertLess(Grade.D, Grade.A) self.assertGreaterEqual(Grade.B, Grade.B) + def test_extending2(self): class Shade(Enum): def shade(self): @@ -923,7 +924,7 @@ class TestEnum(unittest.TestCase): def __new__(cls): value = [len(cls.__members__) + 1] obj = object.__new__(cls) - obj._value = value + obj._value_ = value return obj class ColorInAList(AutoNumberInAList): red = () |