Skip to content

Commit 4048e4c

Browse files
committed
ADD: Missing arrange act assert comments
1 parent 67619f2 commit 4048e4c

17 files changed

+289
-17
lines changed

tests/test_bento_compression.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def test_is_dbn(data: bytes, expected: bool) -> None:
2020
"""
2121
Test that buffers that start with DBN are identified as DBN files.
2222
"""
23+
# Arrange, Act
2324
reader = BytesIO(data)
25+
26+
# Assert
2427
assert is_dbn(reader) == expected
2528

2629

@@ -52,5 +55,8 @@ def test_is_zstandard(data: bytes, expected: bool) -> None:
5255
"""
5356
Test that buffers that contain ZSTD data are correctly identified.
5457
"""
58+
# Arrange, Act
5559
reader = BytesIO(data)
60+
61+
# Assert
5662
assert is_zstandard(reader) == expected

tests/test_bento_data_source.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ def test_memory_data_source(
1515
"""
1616
Test create of MemoryDataSource.
1717
"""
18+
# Arrange, Act
1819
data = test_data(schema)
1920
data_source = MemoryDataSource(data)
2021

22+
# Assert
2123
assert len(data) == data_source.nbytes
2224
assert repr(data) == data_source.name
2325

@@ -30,8 +32,10 @@ def test_file_data_source(
3032
"""
3133
Test create of FileDataSource.
3234
"""
35+
# Arrange, Act
3336
path = test_data_path(schema)
3437
data_source = FileDataSource(path)
3538

39+
# Assert
3640
assert path.stat().st_size == data_source.nbytes
3741
assert path.name == data_source.name

tests/test_common_cram.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ def test_get_challenge_response(
3131
- challenge is the CRAM challenge, this is salt for the hash.
3232
3333
"""
34+
# Arrange, Act
3435
response = cram.get_challenge_response(
3536
challenge=challenge,
3637
key=key,
3738
)
39+
40+
# Assert
3841
assert response == expected

tests/test_common_enums.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
)

tests/test_common_iterator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ def test_chunk(
2929
"""
3030
Test that an iterable is chunked property.
3131
"""
32+
# Arrange, Act, Assert
3233
chunks = [chunk for chunk in iterator.chunk(things, size)]
3334
assert chunks == expected

tests/test_common_parsing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def test_optional_symbols_list_to_list_int(
115115
If integers are given for a different SType we expect a ValueError.
116116
117117
"""
118+
# Arrange, Act, Assert
118119
if isinstance(expected, list):
119120
assert optional_symbols_list_to_list(symbols, stype) == expected
120121
else:
@@ -160,6 +161,7 @@ def test_optional_symbols_list_to_list_numpy(
160161
If integers are given for a different SType we expect a ValueError.
161162
162163
"""
164+
# Arrange, Act, Assert
163165
if isinstance(expected, list):
164166
assert optional_symbols_list_to_list(symbols, stype) == expected
165167
else:
@@ -195,6 +197,7 @@ def test_optional_symbols_list_to_list_raw_symbol(
195197
"""
196198
Test that str are allowed for SType.RAW_SYMBOL.
197199
"""
200+
# Arrange, Act, Assert
198201
if isinstance(expected, list):
199202
assert optional_symbols_list_to_list(symbols, stype) == expected
200203
else:
@@ -267,4 +270,5 @@ def test_datetime_to_unix_nanoseconds(
267270
"""
268271
Test that various inputs for times convert to unix nanoseconds.
269272
"""
273+
# Arrange, Act, Assert
270274
assert optional_datetime_to_unix_nanoseconds(value) == expected

0 commit comments

Comments
 (0)