File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#Complete the funtion to compute how many seconds passed between the two timestamp.
22
def two_timestamp(hr1,min1,sec1,hr2,min2,sec2):
3-
4-
print()
3+
4+
return None
55

66

77
#Invoke the fuction and pass two timestamps(6 intergers) as its argument.
8-
two_timestamp()
8+
print(two_timestamp(1,1,1,2,2,2))
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,12 @@
1-
import io
2-
import sys
3-
sys.stdout = buffer = io.StringIO()
4-
import app
5-
import pytest
1+
import io, sys, pytest, os, re, mock
62

7-
@pytest.mark.it('two_timestamp function is defined')
8-
def test_function(capsys):
9-
assert app.two_timestamp is not None
3+
@pytest.mark.it('The function two_timestamp must exist')
4+
def test_for_functon_existence(capsys, app):
5+
assert callable(app.two_timestamp)
106

11-
12-
13-
@pytest.mark.it('Function prints how many seconds passed between each timestamp')
14-
def test_seconds(capsys):
15-
app.two_timestamp(6,6,6,9,9,9)
16-
captured = capsys.readouterr()
17-
18-
19-
assert captured.out == "10983" + "\n"
20-
21-
22-
23-
@pytest.mark.it('Output cannot be a negative number')
24-
def test_negative_number(capsys):
25-
captured2 = buffer.getvalue()
26-
27-
if "-" in captured2:
28-
assert False
29-
else:
30-
assert True
7+
@pytest.mark.it('We tried passing (1,2,30,4,3,20) as parameters and the function did not return 10850. Keep Trying!')
8+
def test_for_file_output(capsys, app):
9+
assert app.two_timestamp(1,2,30,4,3,20) == ( (3 * 60) + (4 * 3600) + 20 )- ((2 * 60) + (1 * 3600) + 30)
3110

3211

3312

0 commit comments

Comments
 (0)