Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test0(self):
"""handles a height of 0 correctly"""
self.spawn("./mario").stdin("0").stdout(File("0.txt")).exit(0)
def test24(self):
"""rejects a height of 24, and then accepts a height of 2"""
self.spawn("./mario").stdin("24").reject()\
.stdin("2").stdout(File("2.txt")).exit(0)
def append_code(self, original, codefile):
if isinstance(original, File):
original = original.filename
if isinstance(codefile, File):
codefile = codefile.filename
with open(codefile) as code, open(original, "a") as o:
o.write("\n")
o.write(code.read())
def test2(self):
"""handles a height of 2 correctly"""
out = self.spawn("./mario").stdin("2").stdout()
correct = File("2.txt").read()
check_pyramid(out, correct)
def read(self):
with File._open(self.filename) as f:
return f.read()
def test23(self):
"""handles a height of 23 correctly"""
out = self.spawn("./mario").stdin("23").stdout()
correct = File("23.txt").read()
check_pyramid(out, correct)
def test1(self):
"""handles a height of 1 correctly"""
out = self.spawn("./mario").stdin("1").stdout()
correct = File("1.txt").read()
check_pyramid(out, correct)