Repository: RustPython/RustPython
File: Lib/test/test_enum.py (Python)

Code before:
        self.assertEqual(spec.format(member), spec.format(member.value))

    def assertFormatIsStr(self, spec, member):
        self.assertEqual(spec.format(member), spec.format(str(member)))

    def test_attribute_deletion(self):
        class Season(self.enum_type):
            SPRING = auto()
            SUMMER = auto()
            AUTUMN = auto()
            #
            def spam(cls):
                pass
        #
        self.assertHasAttr(Season, 'spam')
        del Season.spam
        self.assertNotHasAttr(Season, 'spam')
        #
        with self.assertRaises(AttributeError):
            del Season.SPRING
        with self.assertRaises(AttributeError):
            del Season.DRY
        with self.assertRaises(AttributeError):
            del Season.SPRING.name

    @unittest.expectedFailure  # TODO: RUSTPYTHON
    def test_bad_new_super(self):
        with self.assertRaisesRegex(
                TypeError,
                'do not use .super...__new__;',
            ):
            class BadSuper(self.enum_type):
                def __new__(cls, value):
                    obj = super().__new__(cls, value)
                    return obj
                failed = 1

    def test_basics(self):
        TE = self.MainEnum
        if self.is_flag:
            self.assertEqual(repr(TE), "<flag 'MainEnum'>")
            self.assertEqual(str(TE), "<flag 'MainEnum'>")
            self.assertEqual(format(TE), "<flag 'MainEnum'>")
            self.assertTrue(TE(5) is self.dupe2)
            self.assertTrue(7 in TE)
        else:
            self.assertEqual(repr(TE), "<enum 'MainEnum'>")
            self.assertEqual(str(TE), "<enum 'MainEnum'>")
            self.assertEqual(format(TE), "<enum 'MainEnum'>")
        self.assertEqual(list(TE), [TE.first, TE.second, TE.third])
        self.assertEqual(

Review comment (bug):
```suggestion
    @unittest.expectedFailure  # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance failed in 'BadSuper'
```

Code after:
        self.assertEqual(spec.format(member), spec.format(member.value))

    def assertFormatIsStr(self, spec, member):
        self.assertEqual(spec.format(member), spec.format(str(member)))

    def test_attribute_deletion(self):
        class Season(self.enum_type):
            SPRING = auto()
            SUMMER = auto()
            AUTUMN = auto()
            #
            def spam(cls):
                pass
        #
        self.assertHasAttr(Season, 'spam')
        del Season.spam
        self.assertNotHasAttr(Season, 'spam')
        #
        with self.assertRaises(AttributeError):
            del Season.SPRING
        with self.assertRaises(AttributeError):
            del Season.DRY
        with self.assertRaises(AttributeError):
            del Season.SPRING.name

    @unittest.expectedFailure  # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance failed in 'BadSuper'
    def test_bad_new_super(self):
        with self.assertRaisesRegex(
                TypeError,
                'do not use .super...__new__;',
            ):
            class BadSuper(self.enum_type):
                def __new__(cls, value):
                    obj = super().__new__(cls, value)
                    return obj
                failed = 1

    def test_basics(self):
        TE = self.MainEnum
        if self.is_flag:
            self.assertEqual(repr(TE), "<flag 'MainEnum'>")
            self.assertEqual(str(TE), "<flag 'MainEnum'>")
            self.assertEqual(format(TE), "<flag 'MainEnum'>")
            self.assertTrue(TE(5) is self.dupe2)
            self.assertTrue(7 in TE)
        else:
            self.assertEqual(repr(TE), "<enum 'MainEnum'>")
            self.assertEqual(str(TE), "<enum 'MainEnum'>")
            self.assertEqual(format(TE), "<enum 'MainEnum'>")
        self.assertEqual(list(TE), [TE.first, TE.second, TE.third])
        self.assertEqual(