Created
December 9, 2011 16:56
-
-
Save spookylukey/1452367 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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