From b34a47772ae08fb5d3984cf11f021ebc33816ec2 Mon Sep 17 00:00:00 2001 From: Filipp <> Date: Sat, 21 Oct 2023 11:38:24 +0300 Subject: [PATCH] Fix test cases logging format. --- tests/unitary/math/test_get_y.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/unitary/math/test_get_y.py b/tests/unitary/math/test_get_y.py index 6a9506c4..0e4ee3b8 100644 --- a/tests/unitary/math/test_get_y.py +++ b/tests/unitary/math/test_get_y.py @@ -1,7 +1,6 @@ # flake8: noqa import time from decimal import Decimal - import pytest from hypothesis import given, note, settings from hypothesis import strategies as st @@ -68,7 +67,7 @@ def test_get_y(math_unoptimized, math_optimized, A, D, xD, yD, gamma, j): A_dec = Decimal(A) / 10000 / 4 - print( + case = ( "{" f"'ANN': {A}, 'GAMMA': {gamma}, 'x': {X}, 'D': {D}, 'index': {j}" "}\n" @@ -82,9 +81,15 @@ def calculate_F_by_y0(y0): result_original = math_unoptimized.newton_y(A, gamma, X, D, j) pytest.gas_original += math_unoptimized._computation.get_gas_used() - result_get_y, K0 = math_optimized.get_y(A, gamma, X, D, j) - pytest.gas_new += math_optimized._computation.get_gas_used() - + try: + result_get_y, K0 = math_optimized.get_y(A, gamma, X, D, j) + pytest.gas_new += math_optimized._computation.get_gas_used() + except Exception as e: + with open("log/get_y_fail.txt", "a") as f: + f.write(case) + with open("log/get_y_fail_trace.txt", "a") as f: + f.write(f'{pytest.current_case_id}:\n{e}\n\n') + return if K0 == 0: pytest.negative_sqrt_arg += 1 @@ -101,3 +106,7 @@ def calculate_F_by_y0(y0): ) or abs(calculate_F_by_y0(result_get_y)) <= abs( calculate_F_by_y0(result_original) ) + + with open("log/get_y_pass.txt", "a") as f: + f.write(case) +