Improve contract Python testcase testing
Catch expected exceptions only - fix bug in test
This commit is contained in:
parent
365d4961d4
commit
7c34d3828f
1 changed files with 23 additions and 23 deletions
|
|
@ -2,16 +2,16 @@ import contract
|
|||
|
||||
contract.test_preassert(1, 2)
|
||||
try:
|
||||
contract.test_preassert(-1)
|
||||
contract.test_preassert(-1, 3)
|
||||
print "Failed! Preassertions are broken"
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
contract.test_postassert(3)
|
||||
try:
|
||||
contract.test_postassert(-3)
|
||||
print "Failed! Postassertions are broken"
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
contract.test_prepost(2, 3)
|
||||
|
|
@ -19,14 +19,14 @@ contract.test_prepost(5, -4)
|
|||
try:
|
||||
contract.test_prepost(-3, 4)
|
||||
print "Failed! Preassertions are broken"
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
contract.test_prepost(4, -10)
|
||||
print "Failed! Postassertions are broken"
|
||||
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
f = contract.Foo()
|
||||
|
|
@ -34,14 +34,14 @@ f.test_preassert(4, 5)
|
|||
try:
|
||||
f.test_preassert(-2, 3)
|
||||
print "Failed! Method preassertion."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
f.test_postassert(4)
|
||||
try:
|
||||
f.test_postassert(-4)
|
||||
print "Failed! Method postassertion"
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
f.test_prepost(3, 4)
|
||||
|
|
@ -49,33 +49,33 @@ f.test_prepost(4, -3)
|
|||
try:
|
||||
f.test_prepost(-4, 2)
|
||||
print "Failed! Method preassertion."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
f.test_prepost(4, -10)
|
||||
print "Failed! Method postassertion."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
contract.Foo_stest_prepost(4, 0)
|
||||
try:
|
||||
contract.Foo_stest_prepost(-4, 2)
|
||||
print "Failed! Static method preassertion"
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
contract.Foo_stest_prepost(4, -10)
|
||||
print "Failed! Static method posteassertion"
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
b = contract.Bar()
|
||||
try:
|
||||
b.test_prepost(2, -4)
|
||||
print "Failed! Inherited preassertion."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -83,54 +83,54 @@ d = contract.D()
|
|||
try:
|
||||
d.foo(-1, 1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, -1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, 1, -1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, 1, 1, -1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, 1, 1, 1, -1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
d.bar(-1, 1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, -1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, 1, -1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, 1, 1, -1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, 1, 1, 1, -1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
# Namespace
|
||||
|
|
@ -138,5 +138,5 @@ my = contract.myClass(1)
|
|||
try:
|
||||
my = contract.myClass(0)
|
||||
print "Failed! constructor preassertion"
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue