Skip to content

Commit

Permalink
test_impl: test StrEnum as well
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <william@trailofbits.com>
  • Loading branch information
woodruffw committed Mar 7, 2024
1 parent e601f16 commit 12aa32e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/test_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import gzip
import json
import struct
from enum import IntEnum
from enum import IntEnum, StrEnum
from io import BytesIO

import pytest
Expand Down Expand Up @@ -112,3 +112,14 @@ class X(IntEnum):

raw = impl.dumps([X.A, X.B, X.C])
assert json.loads(raw) == [1, 2, 9001]


def test_dumps_strenum():
# StrEnum is a subclass of str, so this should work transparently.
class X(StrEnum):
A = "foo"
B = "bar"
C = "baz"

raw = impl.dumps([X.A, X.B, X.C])
assert json.loads(raw) == ["foo", "bar", "baz"]

0 comments on commit 12aa32e

Please sign in to comment.