aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-01 21:26:20 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-01 21:31:09 -0300
commit3c433205280de89d4d7709dfb29426492fdbdbe6 (patch)
treeffd68b0fefae3ec2a2207380b8f9bfbac5448dc5 /tests
parent9fdba4372215c5fe243eacf8ca10ce51904b5d69 (diff)
Removed all undue usage of lambda with assertRaises on unit tests.
Reviewed by Lauro Neto <lauro.neto@openbossa.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/samplebinding/argumentmodifications_test.py2
-rwxr-xr-xtests/samplebinding/derived_test.py2
-rwxr-xr-xtests/samplebinding/enum_test.py4
-rwxr-xr-xtests/samplebinding/modifications_test.py4
-rwxr-xr-xtests/samplebinding/modifiedvirtualmethods_test.py8
-rwxr-xr-xtests/samplebinding/ownership_argument_invalidation_test.py6
-rwxr-xr-xtests/samplebinding/ownership_invalidate_after_use_test.py2
-rwxr-xr-xtests/samplebinding/point_test.py2
8 files changed, 15 insertions, 15 deletions
diff --git a/tests/samplebinding/argumentmodifications_test.py b/tests/samplebinding/argumentmodifications_test.py
index aa75f8c5d..8cf5c4d9f 100755
--- a/tests/samplebinding/argumentmodifications_test.py
+++ b/tests/samplebinding/argumentmodifications_test.py
@@ -84,7 +84,7 @@ class ArgumentModificationsTest(unittest.TestCase):
# void [-> PyObject*] argRemoval4(int, Point [removed, new val = Point(6, 9)], bool, Point = Point(3, 4) [removed], int = 333)
# code-injection: returns tuple with received parameters plus removed ones
a0, a1, a2 = 1, True, 2
- self.assertRaises(TypeError, lambda : self.mods.argRemoval4(a0))
+ self.assertRaises(TypeError, self.mods.argRemoval4, a0)
self.assertEqual(self.mods.argRemoval4(a0, a1), (a0, Point(6, 9), a1, Point(3, 4), 333))
self.assertEqual(self.mods.argRemoval4(a0, a1, a2), (a0, Point(6, 9), a1, Point(3, 4), a2))
diff --git a/tests/samplebinding/derived_test.py b/tests/samplebinding/derived_test.py
index 5077bd591..32d70f49a 100755
--- a/tests/samplebinding/derived_test.py
+++ b/tests/samplebinding/derived_test.py
@@ -94,7 +94,7 @@ class DerivedTest(unittest.TestCase):
def testOverloadedMethodCallWithWrongNumberOfArguments(self):
'''Test if a call to an overloaded method with the wrong number of arguments raises an exception.'''
derived = Derived()
- self.assertRaises(TypeError, lambda : derived.otherOverloaded(1, 2, True))
+ self.assertRaises(TypeError, derived.otherOverloaded, 1, 2, True)
def testReimplementedPureVirtualMethodCall(self):
'''Test if a Python override of a implemented pure virtual method is correctly called from C++.'''
diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py
index d146db421..e282cdc93 100755
--- a/tests/samplebinding/enum_test.py
+++ b/tests/samplebinding/enum_test.py
@@ -36,11 +36,11 @@ class EnumTest(unittest.TestCase):
def testPassingIntegerOnEnumArgument(self):
'''Tries to use an integer in place of an enum argument.'''
- self.assertRaises(TypeError, lambda : SampleNamespace.getNumber(1))
+ self.assertRaises(TypeError, SampleNamespace.getNumber, 1)
def testExtendingNonExtensibleEnum(self):
'''Tries to create a new enum item for an unextensible enum.'''
- self.assertRaises(TypeError, lambda : SampleNamespace.InValue(13))
+ self.assertRaises(TypeError, SampleNamespace.InValue, 13)
def testEnumConversionToAndFromPython(self):
'''Conversion of enum objects from Python to C++ back again.'''
diff --git a/tests/samplebinding/modifications_test.py b/tests/samplebinding/modifications_test.py
index e0c6aa755..9a33c25e1 100755
--- a/tests/samplebinding/modifications_test.py
+++ b/tests/samplebinding/modifications_test.py
@@ -82,7 +82,7 @@ class ModificationsTest(unittest.TestCase):
def testArgumentRemoval(self):
'''Test if second argument of Modifications::doublePlus(int, int) was removed.'''
- self.assertRaises(TypeError, lambda : self.mods.doublePlus(3, 7))
+ self.assertRaises(TypeError, self.mods.doublePlus, 3, 7)
self.assertEqual(self.mods.doublePlus(7), 14)
def testDefaultValueRemoval(self):
@@ -131,7 +131,7 @@ class ModificationsTest(unittest.TestCase):
# the others weren't modified
self.assertEqual(self.mods.overloaded(1, True, 2, False), Modifications.Overloaded_ibib)
self.assertEqual(self.mods.overloaded(1, False, 2, Point(3, 4)), Modifications.Overloaded_ibiP)
- self.assertRaises(TypeError, lambda : self.mods.overloaded(1, True, Point(2, 3), Point(4, 5)))
+ self.assertRaises(TypeError, self.mods.overloaded, 1, True, Point(2, 3), Point(4, 5))
self.assertEqual(self.mods.over(1, True, Point(2, 3), Point(4, 5)), Modifications.Overloaded_ibPP)
if __name__ == '__main__':
diff --git a/tests/samplebinding/modifiedvirtualmethods_test.py b/tests/samplebinding/modifiedvirtualmethods_test.py
index 128c7d1d3..208677695 100755
--- a/tests/samplebinding/modifiedvirtualmethods_test.py
+++ b/tests/samplebinding/modifiedvirtualmethods_test.py
@@ -94,7 +94,7 @@ class VirtualMethodsTest(unittest.TestCase):
result1 = self.vm.sumThree(a0, a1, a2)
self.assertEqual(result0, a0 + a1 + a2)
self.assertEqual(result0, result1)
- self.assertRaises(AttributeError, lambda : self.vm.sum0(a0, a1, a2))
+ self.assertRaises(AttributeError, getattr, self.vm, 'sum0')
def testReimplementedModifiedVirtualMethod0(self):
'''Override of a renamed virtual method.'''
@@ -132,7 +132,7 @@ class VirtualMethodsTest(unittest.TestCase):
result1 = self.vm.sum2(a0, a1)
result2 = self.vm.callSum2(a0, a1, 2000)
self.assertEqual(result1, result2)
- self.assertRaises(TypeError, lambda : self.vm.sum2(1, 2, 3))
+ self.assertRaises(TypeError, self.vm.sum2, 1, 2, 3)
def testReimplementedModifiedVirtualMethod2(self):
'''Override of the virtual method originally with three arguments, the last one was removed and the default value set to 2000.'''
@@ -153,7 +153,7 @@ class VirtualMethodsTest(unittest.TestCase):
self.assertNotEqual(result0, result1)
result2 = self.vm.callSum3(a0, a0 + a1, a1)
self.assertEqual(result0, result2)
- self.assertRaises(TypeError, lambda : self.vm.sum3(1, 2, 3))
+ self.assertRaises(TypeError, self.vm.sum3, 1, 2, 3)
def testReimplementedModifiedVirtualMethod3(self):
'''Override of the virtual method originally with three arguments have the second one removed and replaced
@@ -175,7 +175,7 @@ class VirtualMethodsTest(unittest.TestCase):
removed_arg_value = 100
result1 = self.vm.callSum4(a0, removed_arg_value, a1)
self.assertEqual(result1, a0 + removed_arg_value + a1)
- self.assertRaises(TypeError, lambda : self.vm.sum4(1, 2, 3))
+ self.assertRaises(TypeError, self.vm.sum4, 1, 2, 3)
def testReimplementedModifiedVirtualMethod4(self):
'''Override of the virtual method originally with three arguments, the last one was removed
diff --git a/tests/samplebinding/ownership_argument_invalidation_test.py b/tests/samplebinding/ownership_argument_invalidation_test.py
index 6562a287a..8a6aac79c 100755
--- a/tests/samplebinding/ownership_argument_invalidation_test.py
+++ b/tests/samplebinding/ownership_argument_invalidation_test.py
@@ -38,19 +38,19 @@ class WrapperValidityOfArgumentsTest(unittest.TestCase):
'''Call to method using invalidated Python wrapper as argument should raise RuntimeError.'''
poly = Polygon()
Polygon.stealOwnershipFromPython(poly)
- self.assertRaises(RuntimeError, lambda : Polygon.doublePolygonScale(poly))
+ self.assertRaises(RuntimeError, Polygon.doublePolygonScale, poly)
def testInvalidArgumentToConstructor(self):
'''Call to constructor using invalidated Python wrapper as argument should raise RuntimeError.'''
pt = Point(1, 2)
Polygon.stealOwnershipFromPython(pt)
- self.assertRaises(RuntimeError, lambda : Polygon(pt))
+ self.assertRaises(RuntimeError, Polygon, pt)
def testInvalidArgumentWithImplicitConversion(self):
'''Call to method using invalidated Python wrapper to be implicitly converted should raise RuntimeError.'''
pt = Point(1, 2)
Polygon.stealOwnershipFromPython(pt)
- self.assertRaises(RuntimeError, lambda : Polygon.doublePolygonScale(pt))
+ self.assertRaises(RuntimeError, Polygon.doublePolygonScale, pt)
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/ownership_invalidate_after_use_test.py b/tests/samplebinding/ownership_invalidate_after_use_test.py
index 5f9930e12..80f252d51 100755
--- a/tests/samplebinding/ownership_invalidate_after_use_test.py
+++ b/tests/samplebinding/ownership_invalidate_after_use_test.py
@@ -59,7 +59,7 @@ class OwnershipInvalidateAfterUseTest(unittest.TestCase):
ot = ObjectType()
eot.causeEvent(Event.ANY_EVENT)
self.assertEqual(eot.type_of_last_event, Event.ANY_EVENT)
- self.assertRaises(RuntimeError, lambda : ot.event(eot.last_event))
+ self.assertRaises(RuntimeError, ot.event, eot.last_event)
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/point_test.py b/tests/samplebinding/point_test.py
index 453068503..c5b1bf2e6 100755
--- a/tests/samplebinding/point_test.py
+++ b/tests/samplebinding/point_test.py
@@ -59,7 +59,7 @@ class PointTest(unittest.TestCase):
'''Test Point class != operator.'''
pt1 = Point(5.0, 2.3)
pt2 = Point(5.0, 2.3)
- self.assertRaises(NotImplementedError, lambda : pt1.__ne__(pt2))
+ self.assertRaises(NotImplementedError, pt1.__ne__, pt2)
def testReturnNewCopy(self):
'''Point returns a copy of itself.'''