-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_.py
50 lines (35 loc) · 909 Bytes
/
test_.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# coding: utf-8
from os import environ
from os.path import dirname, join
import pytest
import _ as task
samples = [
# SAMPLES
]
random = [
]
files = [
]
timeout_sec = 2 if "PYDEVD_USE_FRAME_EVAL" not in environ else None
@pytest.mark.timeout(timeout_sec)
@pytest.mark.parametrize('i,o', samples+random)
def test_samples(i, o, capsys):
_test(i, o, capsys)
@pytest.mark.timeout(timeout_sec)
@pytest.mark.parametrize('fi,fo', files)
def test_files(fi, fo, capsys):
_test(
open(join(dirname(__file__), fi), 'r').read().splitlines(),
open(join(dirname(__file__), fo), 'r').read().strip(),
capsys
)
def _test(i, o, capsys):
ans = task.solve(*i)
if isinstance(ans, float):
assert ans == float(o)
else:
assert str(ans) == o
out, _ = capsys.readouterr()
if out:
print(out)
assert False, 'Remove print commands'