def run_tests(): reload_tests() # noinspection PyUnresolvedReferences from client.api import assignment import logging LOGGING_FORMAT = '%(levelname)s | %(filename)s:%(lineno)d | %(message)s' logging.basicConfig(format=LOGGING_FORMAT) log = logging.getLogger('client') # Get top-level logger # noinspection PyUnresolvedReferences from client.cli.ok import parse_input # noinspection PyUnresolvedReferences from client.sources.ok_test.scheme import SchemeSuite # noinspection PyUnresolvedReferences from client.sources.doctest.models import Doctest # noinspection PyUnresolvedReferences from client.sources.scheme_test.models import SchemeTest log.setLevel(logging.ERROR) args = parse_input(["--all", "--verbose"]) assign = assignment.load_assignment(None, args) try: result = [] for test in assign.specified_tests: if isinstance(test, (Doctest, SchemeTest)): # doctests are python continue suites = [] for suite in test.suites: if not isinstance(suite, SchemeSuite): # python ok test continue suites.append( [process_case(case).dictionary for case in suite.cases]) if not suites: continue result.append({ "problem": test.name.replace("-", " ").title(), "suites": suites, "passed": all(x['passed'] for t in suites for x in t) }) return result except TerminatedError: return [{ 'problem': "Tests Terminated by User", 'suites': [], 'passed': False }]
def main(): """Run GradingProtocol and ScoringProtocol.""" args = ok.parse_input() log.setLevel(logging.DEBUG if args.debug else logging.ERROR) log.debug(args) try: assign = assignment.load_assignment(args.config, args) msgs = messages.Messages() grading.protocol(args, assign).run(msgs) scoring.protocol(args, assign).run(msgs) except (ex.LoadingException, ex.SerializeException) as e: log.warning('Assignment could not instantiate', exc_info=True) print('Error: ' + str(e).strip()) exit(1) except (KeyboardInterrupt, EOFError): log.info('Quitting...')
def __init__(self): from client.cli.ok import parse_input self.args = parse_input([])
def test_parse_input(self): old_sys_argv = sys.argv[1:] sys.argv[1:] = [] _ = ok.parse_input() # Does not crash and returns a value. sys.argv[1:] = old_sys_argv
import sys import os from local_server import open_in_browser from client.utils import auth from client.cli.ok import parse_input args = parse_input() args.parsons = True if not auth.authenticate(args): exit(1) open_in_browser(args)
def __init__(self, **kwargs): from client.cli.ok import parse_input self.args = parse_input([]) self.update(**kwargs)
def __init__(self, **kwargs): from client.cli.ok import parse_input self.args = parse_input([]) for k, v in kwargs.items(): setattr(self.args, k, v)