Пример #1
0
def _check_program_string(program):
    with tempman.create_temp_dir() as temp_dir:
        path = os.path.join(temp_dir.path, "main.py")
        with open(path, "w") as main_file:
            main_file.write("#!/usr/bin/env python\n")
            main_file.write(program)
        return nope.check(path=path)
Пример #2
0
def can_import_from_local_package():
    assert nope.check(path=program_path("valid/import_value_from_local_package")).is_valid
Пример #3
0
def cannot_import_from_non_existent_package():
    assert not nope.check(path=program_path("invalid/bad_import")).is_valid
Пример #4
0
def cannot_import_from_executable_module():
    assert not nope.check(path=program_path("invalid/import_executable")).is_valid
Пример #5
0
def calling_function_with_wrong_type_is_invalid():
    assert not nope.check(path=program_path("invalid/wrong_arg_type.py")).is_valid
Пример #6
0
def calling_function_with_correct_type_is_valid():
    assert nope.check(path=program_path("valid/call.py")).is_valid
Пример #7
0
def invalid_syntax_is_invalid_program():
    assert not nope.check(path=program_path("invalid/invalid_syntax.py")).is_valid
Пример #8
0
def fib_program_is_valid():
    assert nope.check(path=program_path("valid/fib.py")).is_valid
Пример #9
0
def print_program_is_valid():
    assert nope.check(path=program_path("valid/print.py")).is_valid
Пример #10
0
def empty_program_is_valid():
    assert nope.check(path=program_path("valid/empty.py")).is_valid
Пример #11
0
 def execute(args):
     result = nope.check(args.path)
     if not result.is_valid:
         _print_error(result.error)
         return 1