Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,19 +872,19 @@ def convert_values(ns_timestamps):
ns_timestamps = self._rounding_values(use_float)
valid_values = convert_values(ns_timestamps)
for time_rnd, decimal_rnd in ROUNDING_MODES :
context = decimal.getcontext()
context.rounding = decimal_rnd

for value in valid_values:
debug_info = {'value': value, 'rounding': decimal_rnd}
try:
result = pytime_converter(value, time_rnd)
expected = expected_func(value)
except Exception as exc:
self.fail("Error on timestamp conversion: %s" % debug_info)
self.assertEqual(result,
expected,
debug_info)
with decimal.localcontext() as context:
context.rounding = decimal_rnd

for value in valid_values:
debug_info = {'value': value, 'rounding': decimal_rnd}
try:
result = pytime_converter(value, time_rnd)
expected = expected_func(value)
except Exception as exc:
self.fail("Error on timestamp conversion: %s" % debug_info)
self.assertEqual(result,
expected,
debug_info)

# test overflow
ns = self.OVERFLOW_SECONDS * SEC_TO_NS
Expand Down