Skip to content

Commit b473745

Browse files
Merge pull request #304 from mishaschwartz/v2.0.2
v2.0.2
2 parents 3b956f5 + 8469391 commit b473745

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# CHANGELOG
22
All notable changes to this project will be documented here.
33

4+
## [unreleased]
5+
6+
## [v2.0.2]
7+
- Keep result object alive for longer than the default 500 seconds (#302)
8+
49
## [v2.0.1]
510
- Update python-ta tester to be compatible with python-ta version 2 (#296)
611
- Improve error message when tester virtual environment fails (#297)

client/autotest_client/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ def run_tests(settings_id, user):
253253
ids.append(id_)
254254
data = {"settings_id": settings_id, "test_id": id_, "files_url": url, "categories": categories, "user": user}
255255
queue.enqueue_call(
256-
"autotest_server.run_test", kwargs=data, job_id=str(id_), timeout=int(timeout * 1.5), failure_ttl=3600
256+
"autotest_server.run_test",
257+
kwargs=data,
258+
job_id=str(id_),
259+
timeout=int(timeout * 1.5),
260+
failure_ttl=3600,
261+
result_ttl=3600,
257262
) # TODO: make this configurable
258263

259264
return {"test_ids": ids}

server/autotest_server/testers/pyta/pyta_tester.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23
import io
34
import json
@@ -8,6 +9,11 @@
89
from ..specs import TestSpecs
910

1011

12+
class PytaReporter(python_ta.reporters.json_reporter.JSONReporter,
13+
python_ta.reporters.plain_reporter.PlainReporter):
14+
pass
15+
16+
1117
class PytaTest(Test):
1218

1319
ERROR_MSGS = {"reported": "{} error(s)"}
@@ -61,12 +67,18 @@ def run(self) -> str:
6167
"""
6268
Return a json string containing all test result information.
6369
"""
64-
tmp_stdout = io.StringIO()
6570
tmp_stderr = io.StringIO()
6671
try:
6772
sys.stderr = tmp_stderr
68-
sys.stdout = tmp_stdout
69-
python_ta.check_all(self.student_file, config=self.tester.pyta_config)
73+
with open(os.devnull, 'w') as devnull:
74+
sys.stdout = devnull
75+
reporter = python_ta.check_all(self.student_file, config=self.tester.pyta_config)
76+
tmp_stdout = io.StringIO()
77+
reporter.out = tmp_stdout
78+
reporter.display_messages(None)
79+
if self.feedback_open:
80+
reporter.out = self.feedback_open
81+
reporter.print_messages()
7082
finally:
7183
sys.stderr = sys.__stderr__
7284
sys.stdout = sys.__stdout__
@@ -118,7 +130,7 @@ def update_pyta_config(self) -> Dict:
118130
else:
119131
config_dict = {}
120132

121-
config_dict["output-format"] = "python_ta.reporters.JSONReporter"
133+
config_dict["output-format"] = "testers.pyta.pyta_tester.PytaReporter"
122134

123135
return config_dict
124136

0 commit comments

Comments
 (0)