|
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 |
6 | 2 |
|
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) |
10 | 6 |
|
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) |
31 | 10 |
|
32 | 11 |
|
33 | 12 |
|
|
0 commit comments