1- import pytest
2- from src .cat_ai .runner import Runner
31from src .cat_ai .reporter import Reporter
2+ from src .cat_ai .runner import Runner
43
54
65# Dummy test function that will be passed to Runner
@@ -12,11 +11,11 @@ def dummy_test_function(reporter: Reporter):
1211def test_runner_sample_size (monkeypatch ):
1312 # Set an environment variable to test
1413 monkeypatch .setenv ("CAT_AI_SAMPLE_SIZE" , "5" )
15- assert Runner .sample_size () == 5
14+ assert Runner .get_sample_size () == 5
1615
1716 # Test default size
1817 monkeypatch .delenv ("CAT_AI_SAMPLE_SIZE" , raising = False )
19- assert Runner .sample_size (default_size = 3 ) == 3
18+ assert Runner .get_sample_size (default_size = 3 ) == 3
2019
2120
2221def test_run_once ():
@@ -32,22 +31,38 @@ def test_run_once():
3231 assert reporter .run_number == 1
3332
3433
35- def test_run_loop (monkeypatch ):
36- # Set the environment variable for a controlled loop
34+ def test_run ():
35+ # Create a Reporter with necessary arguments
36+ reporter = Reporter (test_name = "test_run" , output_dir = "/tmp" )
37+
38+ # Initialize Runner with dummy test function and Reporter
39+ runner = Runner (test_function = dummy_test_function , reporter = reporter )
40+
41+ # Test with explicit sample size parameter
42+ results = runner .run (sample_size = 3 )
43+ assert len (results ) == 3
44+ assert all (res .startswith ("Running test with run number " ) for res in results )
45+ expected_results = [
46+ "Running test with run number 0" ,
47+ "Running test with run number 1" ,
48+ "Running test with run number 2" ,
49+ ]
50+ assert results == expected_results
51+
52+
53+ def test_run_with_env_variable (monkeypatch ):
54+ # Set the environment variable for a controlled test
3755 monkeypatch .setenv ("CAT_AI_SAMPLE_SIZE" , "3" )
3856
3957 # Create a Reporter with necessary arguments
40- reporter = Reporter (test_name = "test_run_loop " , output_dir = "/tmp" )
58+ reporter = Reporter (test_name = "test_run_with_env " , output_dir = "/tmp" )
4159
4260 # Initialize Runner with dummy test function and Reporter
4361 runner = Runner (test_function = dummy_test_function , reporter = reporter )
4462
45- # Test run_loop
46- tries = Runner .sample_size ()
47-
48- results = runner .run_loop (tries = tries )
63+ # Test without explicit sample size (should use environment variable)
64+ results = runner .run ()
4965 assert len (results ) == 3
50- assert all (res .startswith ("Running test with run number " ) for res in results )
5166 expected_results = [
5267 "Running test with run number 0" ,
5368 "Running test with run number 1" ,
0 commit comments