MCPcopy Create free account
hub / github.com/datacamp/pythonwhat / test_running_file_with_root_check

Function test_running_file_with_root_check

tests/test_check_files.py:135–168  ·  view source on GitHub ↗
(temp_py_file)

Source from the content-addressed store, hash-verified

133
134
135def test_running_file_with_root_check(temp_py_file):
136 content = cf.get_file_content(temp_py_file.name)
137 chain = setup_state("", "", pec="")
138
139 with tempfile.TemporaryDirectory() as d:
140 with ChDir(d):
141 chain.check_file(
142 temp_py_file.name, solution_code=content
143 ).run().check_object("a").has_equal_value()
144
145 with tempfile.TemporaryDirectory() as d:
146 with ChDir(d):
147 chain.check_file(
148 temp_py_file.name, solution_code=content
149 ).run().has_no_error()
150
151 with tempfile.TemporaryDirectory() as d:
152 with ChDir(d):
153 chain.check_file(
154 temp_py_file.name, solution_code=content
155 ).run().has_printout(0)
156
157 with pytest.raises(TF):
158 with tempfile.TemporaryDirectory() as d:
159 with ChDir(d):
160 chain.check_file(
161 temp_py_file.name, solution_code="print('Bye!')"
162 ).run().has_printout(0)
163
164 with tempfile.TemporaryDirectory() as d:
165 with ChDir(d):
166 chain.check_file(temp_py_file.name, solution_code=content).run().has_output(
167 "Hi"
168 )

Callers

nothing calls this directly

Calls 3

setup_stateFunction · 0.90
ChDirClass · 0.90
runMethod · 0.80

Tested by

no test coverage detected