Skip to content

Commit 227ad3e

Browse files
committed
Test file checks in Python
1 parent 6073eb6 commit 227ad3e

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

pythonwhat/State.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(
7979
self.params = list()
8080

8181
for k, v in args.items():
82-
if k not in ["self", "args"]:
82+
if k != "self":
8383
self.params.append(k)
8484
setattr(self, k, v)
8585

tests/test_check_files.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from tempfile import NamedTemporaryFile
2+
3+
import pytest
4+
import tests.helper as helper
5+
from protowhat.sct_syntax import F
6+
7+
from pythonwhat.local import setup_state
8+
from protowhat.checks import check_files as cf
9+
10+
11+
@pytest.fixture(scope="function")
12+
def tf():
13+
with NamedTemporaryFile() as tmp:
14+
tmp.file.write(b"1 + 1")
15+
tmp.file.flush()
16+
yield tmp
17+
18+
19+
def test_file_existence(tf):
20+
s = setup_state("", "", pec="")
21+
22+
child = cf.check_file(s._state, tf.name)
23+
assert "1 + 1" in child.student_code
24+
25+
file_chain = s.check_file(tf.name)
26+
assert "1 + 1" in file_chain._state.student_code
27+
28+
with helper.verify_sct(True):
29+
s >> F(attr_scts={"check_file": cf.check_file}).check_file(tf.name)

0 commit comments

Comments
 (0)