How to use the check50.flask.app 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 / flask_tests.py View on Github external
def test_no_app(self):
        with self.assertRaises(check50.Failure):
            check50.flask.app("doesnt_exist.py")
github cs50 / check50 / tests / flask_tests.py View on Github external
def test_app(self):
        src = \
"""from flask import Flask
app = Flask(__name__)

@app.route('/')
def root():
    return ''"""
        with open("hello.py", "w") as f:
            f.write(src)

        app = check50.flask.app("hello.py")
        self.assertIsInstance(app, check50.flask.app)
github cs50 / check50 / tests / flask_tests.py View on Github external
def test_content(self):
        src = \
"""from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'foobar'"""
        with open("hello.py", "w") as f:
            f.write(src)

        app = check50.flask.app("hello.py")
        app.get("/").content("foo")

        with self.assertRaises(check50.Failure):
            app.get("/").content("foo", name="body")

        app.get("/").content("bar")
github cs50 / check50 / tests / flask_tests.py View on Github external
def test_status(self):
        src = \
"""from flask import Flask
app = Flask(__name__)

@app.route('/')
def root():
    return ''"""
        with open("hello.py", "w") as f:
            f.write(src)

        app = check50.flask.app("hello.py")
        app.get("/").status(200)
        app.get("/foo").status(404)
        app.post("/").status(405)
github cs50 / check50 / tests / flask_tests.py View on Github external
def test_raw_content(self):
        src = \
"""from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'hello world'"""
        with open("hello.py", "w") as f:
            f.write(src)

        app = check50.flask.app("hello.py")
        app.get("/").raw_content("hello world")

        with self.assertRaises(check50.Failure):
            app.get("/").raw_content("foo")