Skip to content
Prev Previous commit
Next Next commit
38-sort-tuples-ascending
  • Loading branch information
kiddopro committed Mar 2, 2022
commit a74ba7f75a38a32a822b7222bf8dafd6a4f61ab3
4 changes: 2 additions & 2 deletions exercises/29-remove-duplicate-words/test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest, io, sys, json, mock, re, os

@pytest.mark.it('')
@pytest.mark.it('Your solution should work as expected')
def test_expected_output(capsys, app):
fake_input=['Hola como Hola']
with mock.patch('builtins.input', lambda x: fake_input.pop()):
app()
captured = capsys.readouterr()
assert captured.out != " como \n"
assert captured.out == " como \n"
2 changes: 1 addition & 1 deletion exercises/38-sort-tuples-ascending/solution.hide.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
break
l.append(tuple(s.split(",")))

print sorted(l, key=itemgetter(0,1,2))
print (sorted(l, key=itemgetter(0,1,2)))
11 changes: 11 additions & 0 deletions exercises/38-sort-tuples-ascending/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest, io, sys, json, mock, re, os
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'

@pytest.mark.it('The solution should return the expected output')
def test_convert_inputs(capsys, app):

fake_input = ["Tom,19,80 John,20,90 Jony,17,91 Jony,17,93 Json,21,85"] #fake input
with mock.patch('builtins.input', lambda x: fake_input.pop()):
app()
captured = capsys.readouterr()
assert captured.out == "[('John', '20', '90'), ('Jony', '17', '91'), ('Jony', '17', '93'), ('Json', '21', '85'), ('Tom', '19', '80')]\n"