How to use the check50.Checks 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 / checks / cs50 / 2017 / x / mario / more / checks.py View on Github external
import os
import sys

sys.path.append(os.getcwd())
from check50 import File, Checks, Error, check


class MarioMore(Checks):

    @check()
    def exists(self):
        """mario.c exists."""
        super(MarioMore, self).exists("mario.c")
        self.include("0.txt", "1.txt", "2.txt", "23.txt")

    @check("exists")
    def compiles(self):
        """mario.c compiles."""
        self.spawn("clang -o mario mario.c -lcs50").exit(0)

    @check("compiles")
    def test_reject_negative(self):
        """rejects a height of -1"""
        self.spawn("./mario").stdin("-1").reject().kill()
github cs50 / check50 / check50.py View on Github external
def print_results(results, log=False):
    for result in results:
        if result["status"] == Checks.PASS:
            cprint(":) {}".format(result["description"]), "green")
        elif result["status"] == Checks.FAIL:
            cprint(":( {}".format(result["description"]), "red")
            if result["rationale"] is not None:
                cprint("    {}".format(result["rationale"]), "red")
        elif result["status"] == Checks.SKIP:
            cprint(":| {}".format(result["description"]), "yellow")
            cprint("    {}".format(result.get("rationale") or "check skipped"), "yellow")

        if log:
            for line in result.get("log", []):
                print("    {}".format(line))
github cs50 / check50 / check50.py View on Github external
def __init__(self, method_name):
        super(Checks, self).__init__(method_name)
        self.result = self.FAIL
        self.rationale = None
        self.helpers = None
        self.log = []
        self.children = []
        self.data = {}
github cs50 / check50 / checks / cs50 / 2017 / x / finance / checks.py View on Github external
import os
import re
import sys

sys.path.append(os.getcwd())
from check50 import Checks, Error, check

class Finance(Checks):
    
    @check()
    def exists(self):
        """application.c exists."""
        super(Finance, self).exists("application.py")
github cs50 / check50 / check50.py View on Github external
def print_results(results, log=False):
    for result in results:
        if result["status"] == Checks.PASS:
            cprint(":) {}".format(result["description"]), "green")
        elif result["status"] == Checks.FAIL:
            cprint(":( {}".format(result["description"]), "red")
            if result["rationale"] is not None:
                cprint("    {}".format(result["rationale"]), "red")
        elif result["status"] == Checks.SKIP:
            cprint(":| {}".format(result["description"]), "yellow")
            cprint("    {}".format(result.get("rationale") or "check skipped"), "yellow")

        if log:
            for line in result.get("log", []):
                print("    {}".format(line))
github cs50 / check50 / check50.py View on Github external
def print_results(results, log=False):
    for result in results:
        if result["status"] == Checks.PASS:
            cprint(":) {}".format(result["description"]), "green")
        elif result["status"] == Checks.FAIL:
            cprint(":( {}".format(result["description"]), "red")
            if result["rationale"] is not None:
                cprint("    {}".format(result["rationale"]), "red")
        elif result["status"] == Checks.SKIP:
            cprint(":| {}".format(result["description"]), "yellow")
            cprint("    {}".format(result.get("rationale") or "check skipped"), "yellow")

        if log:
            for line in result.get("log", []):
                print("    {}".format(line))