Skip to content

Commit 66e251c

Browse files
coderabbitai[bot]CodeRabbit
andauthored
fix: apply CodeRabbit auto-fixes
Fixed 1 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
1 parent faa5acc commit 66e251c

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

tests/common/test_decimal_conversion_comparison.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from decimal import Decimal as PyDecimal
44

5+
import pytest
6+
57
from stock_indicators._cstypes import Decimal as CsDecimal
68
from stock_indicators._cstypes.decimal import to_pydecimal, to_pydecimal_via_double
79

@@ -136,36 +138,24 @@ def test_edge_cases_conversion_comparison(self):
136138
]
137139

138140
for py_decimal in test_values:
139-
try:
140-
cs_decimal = CsDecimal(py_decimal)
141-
142-
string_result = to_pydecimal(cs_decimal)
143-
double_result = to_pydecimal_via_double(cs_decimal)
141+
cs_decimal = CsDecimal(py_decimal)
144142

145-
print(f"Testing edge case {py_decimal}:")
146-
print(f" String method: {string_result}")
147-
print(f" Double method: {double_result}")
143+
string_result = to_pydecimal(cs_decimal)
144+
double_result = to_pydecimal_via_double(cs_decimal)
148145

149-
if string_result != double_result:
150-
print(f" Difference: {abs(string_result - double_result)}")
146+
print(f"Testing edge case {py_decimal}:")
147+
print(f" String method: {string_result}")
148+
print(f" Double method: {double_result}")
151149

152-
if string_result is not None and double_result is not None:
153-
assert string_result is not None
154-
assert double_result is not None
150+
if string_result != double_result:
151+
print(f" Difference: {abs(string_result - double_result)}")
155152

156-
except Exception as e:
157-
assert False, str(e)
153+
assert string_result is not None and double_result is not None
158154

159155
def test_edge_case_infinity_raises(self):
160156
"""Test that infinity raises an exception."""
161-
try:
162-
cs_decimal = CsDecimal(float("inf"))
163-
to_pydecimal(cs_decimal)
164-
to_pydecimal_via_double(cs_decimal)
165-
assert False, "Expected exception for infinity was not raised"
166-
except Exception:
167-
# Exception is expected for infinity
168-
pass
157+
with pytest.raises(ValueError, match=r"."):
158+
CsDecimal(float("inf"))
169159

170160
def test_none_input_handling(self):
171161
"""Test that both methods handle None input correctly."""

0 commit comments

Comments
 (0)