diff --git a/test/conftest.py b/test/conftest.py index 196895b779c6c28768ad1bff006588e148f38232..b80d588aa6d96313b89e00790e583df6a6ac6a60 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -48,13 +48,17 @@ def pytest_generate_tests(metafunc): ] metafunc.parametrize('sched_multi', scheds) - if 'test_instance' in metafunc.fixturenames: + if 'test_with_expected_log' in metafunc.fixturenames: instance_files = glob.glob('test/expected_log/*') instances = [basename(instance_file).replace('_jobs.csv', '') for instance_file in instance_files] - metafunc.parametrize('test_instance', instances) + metafunc.parametrize('test_with_expected_log', instances) - + if 'test_with_expected_behavior' in metafunc.fixturenames: + instance_files = glob.glob('test/expected_behavior_log/*') + instances = [basename(instance_file).replace('_user_stats_behaviors.csv', '') + for instance_file in instance_files] + metafunc.parametrize('test_with_expected_behavior', instances) # def pytest_cmdline_preparse(config, args): # html_file = "test-out/testreport.html" diff --git a/test/helper.py b/test/helper.py index e11d20ef5fa1931546cb059af3b07b183dec3745..7f6579ac8b7699883fd9ae706fe4ad62787dac5c 100644 --- a/test/helper.py +++ b/test/helper.py @@ -68,10 +68,13 @@ def assert_expected_output(test_file): Files {expected} and {obtained} should be equal but are not.\n\ Run `diff {expected} {obtained}` to investigate why.\n\ Run `cp {obtained} {expected}` to override the expected file with the obtained." + +def has_expected_behavior(test_file): + return os.path.exists(f"test/expected_behavior_log/{test_file}_user_stats_behaviors.csv") def assert_expected_behavior(test_file) : - expected = "test/expected_behavior_log/" + test_file + "_user_stats_behaviors.csv" - obtained = "test-out/" + test_file + "/user_stats_behaviors.csv" + expected = f"test/expected_behavior_log/{test_file}_user_stats_behaviors.csv" + obtained = f"test-out/{test_file}/user_stats_behaviors.csv" if os.path.exists(expected) : assert filecmp.cmp(expected, obtained), f"\ Files {expected} and {obtained} should be equal but are not.\n\ diff --git a/test/test_users.py b/test/test_users.py index 5be9550062f07985b66db36a775914e5b652f5bf..d7943138b915287726eb664b13798a3aab106f98 100644 --- a/test/test_users.py +++ b/test/test_users.py @@ -61,6 +61,9 @@ def run_user(user_name, platform_multiC, test_name=None, schedconf=None): if has_expected_output(test_name): assert_expected_output(test_name) + if has_expected_behavior(test_name): + assert_expected_behavior(test_name) + return output_dir diff --git a/test/test_zexpected_output.py b/test/test_zexpected_output.py index 93528b0b8c792d4c21a9748f0d7acf3abc3d2446..f87df3797c90a15eb79906846cbef44710bc4c2e 100644 --- a/test/test_zexpected_output.py +++ b/test/test_zexpected_output.py @@ -1,13 +1,14 @@ from helper import * -def test_expected_output(test_instance): +def test_expected_output(test_with_expected_log): """Test for each expected log (thanks to pytest fixtures) that the test was run and the _jobs.csv outputs are strictly equal""" - assert_expected_output(test_instance) + assert_expected_output(test_with_expected_log) -def test_expected_behavior(test_instance) : +def test_expected_behavior(test_with_expected_behavior) : """Test for each expected log (thanks to pytest fixtures) that the test was -run and the user_behavior_stats.csv outputs are strictly equal if they both exists""" - assert_expected_behavior(test_instance) + run and the user_behavior_stats.csv outputs are strictly equal if they both + exists""" + assert_expected_behavior(test_with_expected_behavior)