Skip to content

Commit

Permalink
Merge pull request #304 from mishaschwartz/v2.0.2
Browse files Browse the repository at this point in the history
v2.0.2
  • Loading branch information
mishaschwartz authored Sep 23, 2021
2 parents 3b956f5 + 8469391 commit b473745
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# CHANGELOG
All notable changes to this project will be documented here.

## [unreleased]

## [v2.0.2]
- Keep result object alive for longer than the default 500 seconds (#302)

## [v2.0.1]
- Update python-ta tester to be compatible with python-ta version 2 (#296)
- Improve error message when tester virtual environment fails (#297)
Expand Down
7 changes: 6 additions & 1 deletion client/autotest_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ def run_tests(settings_id, user):
ids.append(id_)
data = {"settings_id": settings_id, "test_id": id_, "files_url": url, "categories": categories, "user": user}
queue.enqueue_call(
"autotest_server.run_test", kwargs=data, job_id=str(id_), timeout=int(timeout * 1.5), failure_ttl=3600
"autotest_server.run_test",
kwargs=data,
job_id=str(id_),
timeout=int(timeout * 1.5),
failure_ttl=3600,
result_ttl=3600,
) # TODO: make this configurable

return {"test_ids": ids}
Expand Down
20 changes: 16 additions & 4 deletions server/autotest_server/testers/pyta/pyta_tester.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
import io
import json
Expand All @@ -8,6 +9,11 @@
from ..specs import TestSpecs


class PytaReporter(python_ta.reporters.json_reporter.JSONReporter,
python_ta.reporters.plain_reporter.PlainReporter):
pass


class PytaTest(Test):

ERROR_MSGS = {"reported": "{} error(s)"}
Expand Down Expand Up @@ -61,12 +67,18 @@ def run(self) -> str:
"""
Return a json string containing all test result information.
"""
tmp_stdout = io.StringIO()
tmp_stderr = io.StringIO()
try:
sys.stderr = tmp_stderr
sys.stdout = tmp_stdout
python_ta.check_all(self.student_file, config=self.tester.pyta_config)
with open(os.devnull, 'w') as devnull:
sys.stdout = devnull
reporter = python_ta.check_all(self.student_file, config=self.tester.pyta_config)
tmp_stdout = io.StringIO()
reporter.out = tmp_stdout
reporter.display_messages(None)
if self.feedback_open:
reporter.out = self.feedback_open
reporter.print_messages()
finally:
sys.stderr = sys.__stderr__
sys.stdout = sys.__stdout__
Expand Down Expand Up @@ -118,7 +130,7 @@ def update_pyta_config(self) -> Dict:
else:
config_dict = {}

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

return config_dict

Expand Down

0 comments on commit b473745

Please sign in to comment.