@@ -42,21 +42,39 @@ class EnumTest(enum.Enum):
4242 """A test enum for ConfigEnumType."""
4343
4444 OPTION_A = auto ()
45+ OPTION_B = auto ()
46+ OPTION_C = OPTION_A | OPTION_B
47+ OPTION_D = OPTION_A & OPTION_B
48+ OPTION_E = OPTION_A ^ OPTION_B
4549
4650class StrEnumTest (enum .StrEnum ):
4751 """A test enum for ConfigEnumType."""
4852
4953 OPTION_A = auto ()
54+ OPTION_B = auto ()
55+ OPTION_C = auto ()
56+ OPTION_D = auto ()
57+ OPTION_E = auto ()
58+ OPTION_F = auto ()
59+ OPTION_G = auto ()
5060
5161class IntEnumTest (enum .IntEnum ):
5262 """A test enum for ConfigEnumType."""
5363
5464 OPTION_A = auto ()
65+ OPTION_B = auto ()
66+ OPTION_C = OPTION_A | OPTION_B
67+ OPTION_D = OPTION_A & OPTION_B
68+ OPTION_E = OPTION_A ^ OPTION_B
5569
5670class IntFlagTest (enum .IntFlag ):
5771 """A test enum for ConfigEnumType."""
5872
5973 OPTION_A = auto ()
74+ OPTION_B = auto ()
75+ OPTION_C = OPTION_A | OPTION_B
76+ OPTION_D = OPTION_A & OPTION_B
77+ OPTION_E = OPTION_A ^ OPTION_B
6078
6179# Having this class exists, tests the functionality of the Config descriptors.
6280# This class will create a test.ini file, which tests writing, reading, editing setting config values.
@@ -269,7 +287,7 @@ def test_none_float(value: float) -> None:
269287 assert t .none_float == value
270288
271289
272- @given (st .integers ())
290+ @given (st .one_of ( st . none (), st . integers () ))
273291def test_optional_number (value : int ) -> None :
274292 t = Test ()
275293 t .optional_number = value
@@ -280,7 +298,7 @@ def test_optional_number(value: int) -> None:
280298 assert t .optional_number3 == value or t .optional_number3 is None
281299
282300
283- @given (st .text ())
301+ @given (st .one_of ( st . none (), st . text () ))
284302def test_optional_string (value : str | None ) -> None :
285303 t = Test ()
286304 t .optional_string = value
@@ -296,7 +314,7 @@ def test_optional_string(value: str | None) -> None:
296314 assert t .optional_string3 == value
297315
298316
299- @given (st .booleans ())
317+ @given (st .one_of ( st . none (), st . booleans () ))
300318def test_optional_boolean (value : bool ) -> None : # noqa: FBT001
301319 t = Test ()
302320 t .optional_boolean = value
@@ -307,7 +325,7 @@ def test_optional_boolean(value: bool) -> None: # noqa: FBT001
307325 assert t .optional_boolean3 == value or t .optional_boolean3 is None
308326
309327
310- @given (st .floats (allow_nan = False ))
328+ @given (st .one_of ( st . none (), st . floats (allow_nan = False ) ))
311329def test_optional_float (value : float ) -> None :
312330 t = Test ()
313331 t .optional_float = value
@@ -482,3 +500,44 @@ def test_list_of_floats(value: list[float]) -> None:
482500 t = Test ()
483501 t .list_of_floats = value
484502 assert t .list_of_floats == value
503+
504+ @given (st .sampled_from (StrEnumTest ))
505+ def test_str_enum_types (value : StrEnumTest ) -> None :
506+ t = Test ()
507+ t .str_enum = value
508+ assert t .str_enum == value
509+
510+
511+ @given (st .sampled_from (IntEnumTest ))
512+ def test_int_enum_types (value : IntEnumTest ) -> None :
513+ t = Test ()
514+ t .int_enum = value
515+ assert t .int_enum == value
516+
517+
518+ @given (st .sampled_from (IntFlagTest ))
519+ def test_int_flag_enum_types (value : IntFlagTest ) -> None :
520+ t = Test ()
521+ t .int_flag = value
522+ assert t .int_flag == value
523+
524+
525+ @given (st .one_of (st .none (), st .sampled_from (StrEnumTest )))
526+ def test_optional_str_enum_types (value : StrEnumTest ) -> None :
527+ t = Test ()
528+ t .optional_str_enum = value
529+ assert t .optional_str_enum == value
530+
531+
532+ @given (st .one_of (st .none (), st .sampled_from (IntEnumTest )))
533+ def test_optional_int_enum_types (value : IntEnumTest ) -> None :
534+ t = Test ()
535+ t .optional_int_enum = value
536+ assert t .optional_int_enum == value
537+
538+
539+ @given (st .one_of (st .none (), st .sampled_from (IntFlagTest )))
540+ def test_optional_int_flag_enum_types (value : IntFlagTest ) -> None :
541+ t = Test ()
542+ t .optional_int_flag = value
543+ assert t .optional_int_flag == value
0 commit comments