def test_file_with_numbers(tmpdir): """Testing that file with integers gives min and max of integers.""" text = "1\n2\n3\n4\n5\n-5\n" temp_file = tmpdir.join("file.txt") with open(temp_file, "w"): temp_file.write(text) assert find_maximum_and_minimum(temp_file) == (-5, 5)
def test_positive_case1(): """Testing that function finds max and min number correctly""" assert find_maximum_and_minimum( "tests/homework1/test_task03_data1.txt") == ( -10, 22, )
def test_file_with_one_number(tmpdir): """Testing that file with one integer gives that integer as min and max.""" text = "3\n" temp_file = tmpdir.join("file.txt") with open(temp_file, "w"): temp_file.write(text) assert find_maximum_and_minimum(temp_file) == (3, 3)
def test_same_nums(tmp_path): """Testing that sequence of same numbers returns tuple with same numbers""" d = tmp_path some_file = d / "test_02_same_nums.txt" some_file.write_text( """9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 """ ) assert find_maximum_and_minimum(some_file) == (9, 9)
def test_sequence(tmp_path): """Testing that on sequence of integers returns min and max""" d = tmp_path some_file = d / "test_02_sequence.txt" some_file.write_text( """5 7 9 -2 0 11 3 5 6 -4 7 4 77 4 4 """ ) assert find_maximum_and_minimum(some_file) == (-4, 77)
def test_min_max(task03_file, file_data, expected_result): with open(task03_file, "w") as test_file: test_file.write("\n".join(file_data)) actual_result = find_maximum_and_minimum(task03_file) assert actual_result == expected_result
def test_min_max(file_name: str, mini: int, maxi: int): """Testing that file.txt will be read and min and max values will be returned as a tuple: for some lines, for one line""" assert find_maximum_and_minimum(file_name) == (mini, maxi)
def test_empty_file(tmp_path): """Testing that func on empty file returns None and prints that file is empty""" d = tmp_path some_file = d / "test_02_empty.txt" some_file.write_text("") assert find_maximum_and_minimum(some_file) == ()
def test_1_num(tmp_path): """Testing that func on file with 1 number returns that number and prints that only 1 number""" d = tmp_path some_file = d / "test_02_1_num.txt" some_file.write_text("5") assert find_maximum_and_minimum(some_file) == (5, 5)
def test_min_max(value: str, expected_result: Tuple[int, int]): actual_result = find_maximum_and_minimum(value) assert actual_result == expected_result