* update MANIFEST file
- 3.1.10
* improve tests
- 3.1.9
* fail gracefully for badly written EnumType
- 3.1.8
* recalculate bits used after all flags created (sometimes needed when a
custom `__new__` is in place.
- 3.1.7
* update flag creation to (possibly) add bitwise operator methods to newly
created flags
* update extend_enum() to work with 3.11 flags
- 3.1.6
* Update `dir()` on mixed enums to include mixed data type methods and
attributes.
* Rename `enum_property` to `property` to match stdlib. Recommended usage is
`aenum.property` (prefix with module name).
* Remove quadritic creation behavior.
BREAKING CHANGE BUG FIX that won't affect most people
Enums with a custom `__new__` that:
- use the enum machinery to generate the values; AND
- have keyword arguments set to a default (like `None`)
will fail to generate a missing value. To fix: remove the default value and
instead specify it on the member creation line.
BREAKING CHANGE
In Python 3.11 the `str()` of mixed enums will now match its `format()` which
will be the normal `str()` of the data type -- so for an IntEnum you'll see
`5` instead of `Perm.R|X`. This affects IntEnum, StrEnum, and IntFlag.
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-aenum?expand=0&rev=17
87 lines
3.0 KiB
Diff
87 lines
3.0 KiB
Diff
---
|
|
aenum/test.py | 32 ++++++++++++++++----------------
|
|
1 file changed, 16 insertions(+), 16 deletions(-)
|
|
|
|
Index: aenum-3.1.11/aenum/test.py
|
|
===================================================================
|
|
--- aenum-3.1.11.orig/aenum/test.py
|
|
+++ aenum-3.1.11/aenum/test.py
|
|
@@ -51,13 +51,18 @@ def load_tests(loader, tests, ignore):
|
|
return tests
|
|
|
|
class TestCase(unittest.TestCase):
|
|
-
|
|
def __init__(self, *args, **kwds):
|
|
regex = getattr(self, 'assertRaisesRegex', None)
|
|
if regex is None:
|
|
self.assertRaisesRegex = getattr(self, 'assertRaisesRegexp')
|
|
super(TestCase, self).__init__(*args, **kwds)
|
|
|
|
+ def setUp(self):
|
|
+ self.tempdir = tempfile.mkdtemp()
|
|
+ if pyver >= (3, ):
|
|
+ test_v3.tempdir = self.tempdir
|
|
+ # self.addCleanup(shutil.rmtree, self.tempdir, True)
|
|
+
|
|
|
|
# for pickle tests
|
|
try:
|
|
@@ -940,6 +945,8 @@ class TestEnum(TestCase):
|
|
IDES_OF_MARCH = 2013, 3, 15
|
|
self.Holiday = Holiday
|
|
|
|
+ super(TestEnum, self).setUp()
|
|
+
|
|
def test_set_name(self):
|
|
class Descriptor(object):
|
|
name = None
|
|
@@ -2081,7 +2088,7 @@ class TestEnum(TestCase):
|
|
# for use with both Python 2/3
|
|
JSONEnum = JSONEnumMeta('JsonEnum', (Enum, ), {})
|
|
|
|
- test_file = os.path.join(tempdir, 'test_json.json')
|
|
+ test_file = os.path.join(self.tempdir, 'test_json.json')
|
|
with open(test_file, 'w') as f:
|
|
f.write(
|
|
'[{"name":"Afghanistan","alpha-2":"AF","country-code":"004","notes":{"description":"pretty"}},'
|
|
@@ -4040,6 +4047,8 @@ class TestFlag(TestCase):
|
|
CE = 1<<19
|
|
self.Open = Open
|
|
|
|
+ super(TestFlag, self).setUp()
|
|
+
|
|
def test_set_name(self):
|
|
class Descriptor(object):
|
|
name = None
|
|
@@ -4338,7 +4347,7 @@ class TestFlag(TestCase):
|
|
self.assertEqual(AS.STREET._value_, 32)
|
|
self.assertEqual(AS.SECONDARY_TYPE._value_, 128)
|
|
self.assertEqual((AS.NAME | AS.STREET)._value_, 48, "%r is not 48" % (AS.NAME | AS.STREET))
|
|
-
|
|
+
|
|
def test_iteration(self):
|
|
C = self.Color
|
|
self.assertEqual(list(C), [C.RED, C.GREEN, C.BLUE])
|
|
@@ -5025,6 +5034,8 @@ class TestIntFlag(TestCase):
|
|
self.Color = Color
|
|
self.Open = Open
|
|
|
|
+ super(TestIntFlag, self).setUp()
|
|
+
|
|
def test_set_name(self):
|
|
class Descriptor(object):
|
|
name = None
|
|
@@ -6197,10 +6208,10 @@ class TestStackoverflowAnswers(TestCase)
|
|
fh.write('#define %s %r\n' % (enum.name, enum.value))
|
|
class Arduino(CHeader):
|
|
_order_ = 'ONE TWO'
|
|
- __header = os.path.join(tempdir, 'arduino.h')
|
|
+ __header = os.path.join(self.tempdir, 'arduino.h')
|
|
ONE = 1
|
|
TWO = 2
|
|
- with open(os.path.join(tempdir, 'arduino.h')) as fh:
|
|
+ with open(os.path.join(self.tempdir, 'arduino.h')) as fh:
|
|
data = fh.read()
|
|
self.assertEqual(textwrap.dedent("""\
|
|
initial header stuff here
|