11
22import pytest ,os ,re ,io ,sys , mock , json
33
4- @pytest .mark .it ('The solution must return the expected value for an input like "3,5"' )
5- def test_for_output_3_5 (capsys , app ):
6- fake_input = ["3,5" ]
7- with mock .patch ('builtins.input' , lambda x : fake_input .pop ()):
8- app ()
9- captured = capsys .readouterr ()
10- assert captured .out == "[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]\n "
4+ @pytest .mark .it ('The function two_dimensional_array must exist' )
5+ def test_function_existence (capsys , app ):
6+ assert app .two_dimensional_array
117
12-
13-
14- @pytest .mark .it ('Your solution should work with others input values, testing with: 2,7' )
15- def test_for_output_2_7 (capsys , app ):
16- fake_input = ["2,7" ]
17- with mock .patch ('builtins.input' , lambda x : fake_input .pop ()):
18- app ()
19- captured = capsys .readouterr ()
20- assert captured .out == "[[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6]]\n "
8+ @pytest .mark .it ('The function should return the expected output.' )
9+ def test_expected_output (capsys , app ):
10+ assert app .two_dimensional_array (3 ,5 ) == [[0 , 0 , 0 , 0 , 0 ], [0 , 1 , 2 , 3 , 4 ], [0 , 2 , 4 , 6 , 8 ]]
2111
22- @pytest .mark .it ('The input must be two numbers separate by comma, like this: 7,8 ' )
23- def test_input (capsys , app ):
24- fake_input = [ "2,7" ]
25- with mock . patch ( 'builtins.input' , lambda x : fake_input . pop ()):
26- app ( )
27- captured = capsys . readouterr ()
28- assert captured . out == " [[0, 0, 0, 0, 0, 0, 0], [ 0, 1, 2, 3, 4, 5, 6]] \n "
12+ @pytest .mark .it ('The function should work with other entries. Testing with 2,7 ' )
13+ def test_expected_output (capsys , app ):
14+ assert app . two_dimensional_array ( 2 , 7 ) == [[ 0 , 0 , 0 , 0 , 0 , 0 , 0 ], [ 0 , 1 , 2 , 3 , 4 , 5 , 6 ] ]
15+
16+ @ pytest . mark . it ( 'The function should work with other entries. Testing with 2,7' )
17+ def test_expected_output ( capsys , app ):
18+ assert app . two_dimensional_array ( 1 , 10 ) == [[0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]]
0 commit comments