Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# from unitgrade.unitgrade import QuestionGroup, Report, QPrintItem
# from unitgrade.unitgrade_helpers import evaluate_report_student
from cs202courseware import homework1
import unittest
from unitgrade2.unitgrade2 import wrapper, UTestCase, cache
# from unitgrade2.unitgrade2 import cache
from unitgrade2.unitgrade2 import methodsWithDecorator, hide
import random
from cs101courseware_example.homework1 import reverse_list, my_sum
class GeneratorQuestion(UTestCase):
def genTest(self, n):
seq = [random.randint(1, 100000) for _ in range(n)]
return my_sum(seq)
class ListQuestion(UTestCase):
""" Docstring at top """
@classmethod
def setUpClass(cls) -> None:
z = 23424
# print(" calling setUpClass()...")
pass
def test_integers(self):
""" aa test_integers-short """
self.__class__.a = "fun1"
from cs101courseware_example.homework1 import reverse_list
# self.a = self.a + 2
self.assertEqual(reverse_list([1, 2, 3]), [3, 2, 1])
self.assertEqualC(reverse_list([1,2,3]))
self.assertEqualC(reverse_list(["23", "asdfsadf"]))
return dict(title="test integers...")
@cache
def my_funny_computation(self, a):
return a*2
def test_strings(self):
""" xxxxtest_integers-short """
# import time
# time.sleep(1.1)
a = self.my_funny_computation(2)
from cs101courseware_example.homework1 import reverse_list
l = ["hello", "world", "summer", "dog"]
self.assertEqual(reverse_list(l), list(reversed(l)))
def test_more_integerrs(self):
""" ccc test_integers-short """
self.assertEqual(2,2)
from unitgrade2.unitgrade2 import Report
class Report1(Report):
title = "CS 202 Report 1"
questions = [
(GeneratorQuestion, 10),
(ListQuestion, 5)
]
import cs202courseware
pack_imports = [cs202courseware] # Include this file in .token file
a = 234
def docker_test_uploads(student_id, student_file, source_repo_report_class, student_repo_report_class):
# The student file contains a list of all uploaded files.
source_base_dir = "" # Location of all source files for project. Must be the 'real' version required to get project to run.
# Or should it be? Why?
# Need a directory where we are going to work. must be the image location.
docker_image_location = ""
# Make a tmp location in docker directory.
docker_tmp_file_system = docker_image_location + "/tmp"
# This is where the docker file system is going to run.
import pickle
with open(student_file, 'rb') as f:
upload = pickle.load(f)
# report-location is given in the student repo (within their fs relative to root).
# Now we have the upload.
pass
if __name__ == "__main__":
"""
Capture output in TestCase
HTML test runner:
https://awesomeopensource.com/project/oldani/HtmlTestRunner
"""
import inspect
ls = list(methodsWithDecorator(GeneratorQuestion, hide))
for f in ls:
print(inspect.getsourcelines(f) ) # How to get all hidden questions.
from unitgrade2.unitgrade_helpers2 import evaluate_report_student
evaluate_report_student( Report1() )
# unittest.main(verbosity=2)
# deploy the report
from unitgrade_private2.hidden_create_files import setup_grade_file_report
setup_grade_file_report(Report1, minify=False, obfuscate=False, execute=False)