summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests/test_code_evaluation.py
blob: cbca32dbc0ea4c9aaa39d7400c1ef101a76f9627 (plain)
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
import unittest
import os
from yaksh import python_assertion_evaluator
from yaksh.language_registry import _LanguageRegistry, get_registry
from yaksh.settings import SERVER_TIMEOUT, code_evaluators


class RegistryTestCase(unittest.TestCase):
    def setUp(self):
        self.registry_object = get_registry()
        self.language_registry = _LanguageRegistry()
        assertion_evaluator_path = ("yaksh.python_assertion_evaluator"
            ".PythonAssertionEvaluator"
        )
        stdout_evaluator_path = ("yaksh.python_stdout_evaluator."
            "PythonStdoutEvaluator"
        )
        code_evaluators['python'] = \
        {"standardtestcase": assertion_evaluator_path,
        "stdiobasedtestcase": stdout_evaluator_path
        }

    def test_set_register(self):
        evaluator_class = self.registry_object.get_class("python", 
            "standardtestcase"
        )
        assertion_evaluator_path = ("yaksh.python_assertion_evaluator"
            ".PythonAssertionEvaluator"
        )
        stdout_evaluator_path = ("yaksh.python_stdout_evaluator."
            "PythonStdoutEvaluator"
        )
        class_name = getattr(python_assertion_evaluator, 
            'PythonAssertionEvaluator'
        )
        self.registry_object.register("python", 
            {"standardtestcase": assertion_evaluator_path,
                "stdiobasedtestcase": stdout_evaluator_path
            }
        )
        self.assertEquals(evaluator_class, class_name)

    def tearDown(self):
        self.registry_object = None


if __name__ == '__main__':
    unittest.main()