summaryrefslogtreecommitdiff
path: root/monkey/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'monkey/test.py')
-rwxr-xr-xmonkey/test.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/monkey/test.py b/monkey/test.py
index 9936cdc..03f3571 100755
--- a/monkey/test.py
+++ b/monkey/test.py
@@ -18,30 +18,29 @@ from .util import indent
if len(sys.argv) < 2:
print('usage: ' + sys.argv[0] + ' <pid>')
sys.exit(1)
-pid = int(sys.argv[1])
-language, problem_group, problem = Problem.get_identifier(pid)
+problem = Problem.get(id=sys.argv[1])
-solved_problems = [p for p in CodeqUser.solved_problems(1, language)
- if p != (problem_group, problem)]
-other_solutions = server.problems.solutions_for_problems(language, solved_problems)
-problem_module = server.problems.load_problem(language, problem_group, problem, 'common')
-name = server.problems.load_problem(language, problem_group, problem, 'en').name
+solved_problems = [p for p in CodeqUser.solved_problems(1, problem.language)
+ if p != (problem.group, problem.identifier)]
+other_solutions = server.problems.solutions_for_problems(problem.language, solved_problems)
+problem_module = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'common')
+name = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'en').name
# Testing function.
def test(code):
correct, hints = problem_module.test(code, solved_problems)
return correct
-traces = [s.trace for s in Solution.filter(problem_id=pid)]
+traces = [s.trace for s in Solution.filter(problem_id=problem.id)]
# Load hint database stored in edits.pickle.
edits, submissions, queries, names = pickle.load(open('edits.pickle', 'rb'))
-edits, submissions, queries, names = edits[pid], submissions[pid], queries[pid], names[pid]
+edits, submissions, queries, names = edits[problem.id], submissions[problem.id], queries[problem.id], names[problem.id]
# Load current status (programs for which a hint was found).
try:
- done = pickle.load(open('status-'+str(problem.pk)+'.pickle', 'rb'))
+ done = pickle.load(open('status-'+str(problem.id)+'.pickle', 'rb'))
except:
done = []
@@ -106,7 +105,7 @@ elif sys.argv[2] == 'test':
print_hint(program, solution, steps, fix_time, n_tested)
print()
- pickle.dump(done, open('status-'+str(problem.pk)+'.pickle', 'wb'))
+ pickle.dump(done, open('status-'+str(problem.id)+'.pickle', 'wb'))
print('Found hints for ' + str(len(done)) + ' of ' + str(len(incorrect)) + ' incorrect programs')
@@ -115,7 +114,7 @@ elif sys.argv[2] == 'info':
# With no additional arguments, print some stats.
if len(sys.argv) == 3:
print('Problem {} ({}): {} edits and {} unique submissions in {} traces'.format(
- pid, colored(name, 'yellow'),
+ problem.id, colored(name, 'yellow'),
colored(str(len(edits)), 'yellow'),
colored(str(len(submissions)), 'yellow'),
colored(str(len(traces)), 'yellow')))
@@ -146,7 +145,7 @@ elif sys.argv[2] == 'info':
# Print the edit graph in graphviz dot syntax.
elif sys.argv[2] == 'graph' and len(sys.argv) == 4:
uid = int(sys.argv[3])
- solution = Solution.get(problem_id=pid, codeq_user_id=uid)
+ solution = Solution.get(problem_id=problem.id, codeq_user_id=uid)
nodes, submissions, queries = trace_graph(solution.trace)