Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_leak(self):
with open("leak.c", "w") as f:
src = '#include \n'\
'void leak() {malloc(sizeof(int));}\n'\
'int main() {\n'\
' leak();\n'\
'}'
f.write(src)
check50.c.compile("leak.c")
with self.assertRaises(check50.Failure):
with check50.internal.register:
check50.c.valgrind("./leak").exit()
def exists4():
"""foo.py exists"""
raise check50.Failure()
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")
def check():
check50.log("AHHHHHHHHHHHHHHHHHHH")
raise check50.Failure("AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH")
def test_file(self):
self.write("print('bar')")
self.runpy()
with open(self.txt_filename, "r") as f:
with self.assertRaises(check50.Failure):
self.process.stdout(f, regex=False)
self.write("print('foo')")
self.runpy()
with open(self.txt_filename, "r") as f:
self.process.stdout(f, regex=False)