How to use the check50.run function in check50

To help you get started, we’ve selected a few check50 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cs50 / check50 / tests / checks / stdin_multiline / check.py View on Github external
def prints_hello_name_chaining():
    """prints hello name (chaining)"""
    check50.run("python3 foo.py").stdin("bar").stdout("hello bar").stdin("baz").stdout("hello baz")
github cs50 / check50 / tests / api_tests.py View on Github external
def test_returns_process(self):
        self.process = check50.run("python3 ./{self.filename}")
github cs50 / check50 / tests / c_tests.py View on Github external
def test_compile_hello_world(self):
        with open("hello.c", "w") as f:
            src =   '#include \n'\
                    'int main() {\n'\
                    '    printf("hello, world!\\n");\n'\
                    '}'
            f.write(src)

        check50.c.compile("hello.c")

        self.assertTrue(os.path.isfile("hello"))
        check50.run("./hello").stdout("hello, world!", regex=False)
github cs50 / check50 / tests / checks / stdin_multiline / check.py View on Github external
def prints_hello_name_non_chaining():
    """prints hello name (non chaining)"""
    check50.run("python3 foo.py").stdin("bar\nbaz").stdout("hello bar").stdout("hello baz")
github cs50 / check50 / tests / api_tests.py View on Github external
def runpy(self):
        self.process = check50.run(f"python3 ./{self.filename}")
github cs50 / check50 / tests / checks / stdin_multiline / check.py View on Github external
def prints_hello_name_non_chaining_prompt():
    """prints hello name (non chaining) (prompt)"""
    check50.run("python3 foo.py").stdin("bar\nbaz", prompt=True).stdout("hello bar").stdout("hello baz")
github cs50 / check50 / check50 / c / c.py View on Github external
def compile(file_name, exe_name=None):
    if exe_name is None and file_name.endswith(".c"):
        exe_name = file_name.split(".c")[0]

    out_flag = f"-o {exe_name}" if exe_name is not None else ""

    check50.run(f"{CC} {file_name} {out_flag} {CFLAGS}").exit(0)