Skip to content

Instantly share code, notes, and snippets.

@spookylukey
Created December 9, 2011 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spookylukey/1452367 to your computer and use it in GitHub Desktop.
Save spookylukey/1452367 to your computer and use it in GitHub Desktop.
# 100% code coverage, with an obvious type level bug that is not caught - Bar
# does not define method2 and do_it will fail for some values.
class Foo(object):
def method1(self, arg):
return arg + 1
def method2(self, arg):
return arg + 2
class Bar(object):
def method1(self, arg):
return arg - 1
def do_it(obj, val):
retval = obj.method1(val)
if retval > 10:
return obj.method2(val)
else:
return retval
def test_Foo():
assert do_it(Foo(), 10) == 12
def test_Bar():
assert do_it(Bar(), 10) == 9
if __name__ == '__main__':
test_Foo()
test_Bar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment