@@ -52,8 +52,9 @@ def test_int_enum_string_coercion(enum_type: type[Enum]) -> None:
5252 See: databento.common.enums.coercible
5353
5454 """
55- for enum in enum_type :
56- assert enum == enum_type (str (enum .value ))
55+ # Arrange, Act, Assert
56+ for variant in enum_type :
57+ assert variant == enum_type (str (variant .value ))
5758 with pytest .raises (ValueError ):
5859 enum_type ("NaN" ) # sanity
5960
@@ -69,6 +70,7 @@ def test_str_enum_case_coercion(enum_type: type[Enum]) -> None:
6970 See: databento.common.enums.coercible
7071
7172 """
73+ # Arrange, Act, Assert
7274 for enum in enum_type :
7375 assert enum == enum_type (enum .value .lower ())
7476 assert enum == enum_type (enum .value .upper ())
@@ -88,11 +90,13 @@ def test_enum_name_coercion(enum_type: type[Enum]) -> None:
8890 See: databento.common.enums.coercible
8991
9092 """
93+ # Arrange, Act
9194 if enum_type in (Compression , Encoding , Schema , SType ):
9295 enum_it = iter (enum_type .variants ()) # type: ignore [attr-defined]
9396 else :
9497 enum_it = iter (enum_type )
9598
99+ # Assert
96100 for enum in enum_it :
97101 assert enum == enum_type (enum .name )
98102 assert enum == enum_type (enum .name .replace ("_" , "-" ))
@@ -113,9 +117,11 @@ def test_enum_none_not_coercible(enum_type: type[Enum]) -> None:
113117 See: databento.common.enum.coercible
114118
115119 """
120+ # Arrange, Act
116121 if enum_type == Compression :
117122 enum_type (None )
118123 else :
124+ # Assert
119125 with pytest .raises (ValueError ):
120126 enum_type (None )
121127
@@ -131,8 +137,11 @@ def test_int_enum_stringy_mixin(enum_type: type[Enum]) -> None:
131137 See: databento.common.enum.StringyMixin
132138
133139 """
140+ # Arrange, Act
134141 if not issubclass (enum_type , StringyMixin ):
135142 pytest .skip (f"{ type (enum_type )} is not a subclass of StringyMixin" )
143+
144+ # Assert
136145 for enum in enum_type :
137146 assert str (enum ) == enum .name .lower ()
138147
@@ -148,8 +157,11 @@ def test_str_enum_stringy_mixin(enum_type: type[Enum]) -> None:
148157 See: databento.common.enum.StringyMixin
149158
150159 """
160+ # Arrange, Act
151161 if not issubclass (enum_type , StringyMixin ):
152162 pytest .skip (f"{ type (enum_type )} is not a subclass of StringyMixin" )
163+
164+ # Assert
153165 for enum in enum_type :
154166 assert str (enum ) == enum .value
155167
@@ -162,8 +174,11 @@ def test_int_flags_stringy_mixin(enum_type: type[Flag]) -> None:
162174 """
163175 Test that combinations of int flags are displayed properly.
164176 """
177+ # Arrange, Act
165178 for value in map (sum , combinations (enum_type , 2 )): # type: ignore [arg-type]
166179 record_flags = enum_type (value )
180+
181+ # Assert
167182 assert str (record_flags ) == ", " .join (
168183 f .name .lower () for f in enum_type if f in record_flags
169184 )
0 commit comments