From f5ba14575c9555b1d957f86d54f57050f129efdd Mon Sep 17 00:00:00 2001 From: anabwan <46447582+anabwan@users.noreply.github.com> Date: Tue, 28 May 2019 13:45:43 +0300 Subject: [PATCH] tests: print logs on failure + fix -cp param (#327) * tests: pring logs on failure * fix import * added job to circleci * fix functional * removed debug job --- rl_coach/tests/test_coach_args.py | 3 +++ rl_coach/tests/utils/args_utils.py | 23 ++++++++--------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/rl_coach/tests/test_coach_args.py b/rl_coach/tests/test_coach_args.py index d6aa9c7..1ff67c2 100644 --- a/rl_coach/tests/test_coach_args.py +++ b/rl_coach/tests/test_coach_args.py @@ -18,6 +18,7 @@ import time import pytest import rl_coach.tests.utils.args_utils as a_utils import rl_coach.tests.utils.presets_utils as p_utils +from rl_coach.logger import screen from rl_coach.tests.utils.definitions import Definitions as Def @@ -59,6 +60,8 @@ def test_preset_args(preset_args, flag, clres, start_time=time.time(), except AssertionError: # close process once get assert false proc.kill() + # if test failed - print logs + screen.error(open(clres.stdout.name).read(), crash=False) assert False proc.kill() diff --git a/rl_coach/tests/utils/args_utils.py b/rl_coach/tests/utils/args_utils.py index bf36400..0f1c584 100644 --- a/rl_coach/tests/utils/args_utils.py +++ b/rl_coach/tests/utils/args_utils.py @@ -385,23 +385,16 @@ def validate_arg_result(flag, p_valid_params, clres=None, process=None, csv = pd.read_csv(csv_path[0]) # check heat-up value - results = [] - if csv["In Heatup"].values[-1] == 0: - results.append(csv["Total steps"].values[-1]) - else: - while csv["In Heatup"].values[-1] == 1: - csv = pd.read_csv(csv_path[0]) - last_step = csv["Total steps"].values - results.append(last_step[-1]) - time.sleep(1) + while csv["In Heatup"].values[-1] == 1: + csv = pd.read_csv(csv_path[0]) + time.sleep(1) - # get the first value after heat-up - time.sleep(3) - results.append(csv["Total steps"].values[-1]) - - assert int(results[-1]) >= Def.Consts.num_hs, \ + csv.columns = [column.replace(" ", "_") for column in csv.columns] + results = csv.query("In_Heatup == 1") + last_val_in_heatup = results.Total_steps.values[-1] + assert int(last_val_in_heatup) >= Def.Consts.num_hs, \ Def.Consts.ASSERT_MSG.format("bigger than " + - str(Def.Consts.num_hs), results[-1]) + str(Def.Consts.num_hs), last_val_in_heatup) elif flag[0] == "-f" or flag[0] == "--framework": """