Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -73,6 +73,44 @@ class Bindings(NewOpenCVTests):
|
||||
except cv.error as _e:
|
||||
pass
|
||||
|
||||
def test_overload_resolution_can_choose_correct_overload(self):
|
||||
val = 123
|
||||
point = (51, 165)
|
||||
self.assertEqual(cv.utils.testOverloadResolution(val, point),
|
||||
'overload (int={}, point=(x={}, y={}))'.format(val, *point),
|
||||
"Can't select first overload if all arguments are provided as positional")
|
||||
|
||||
self.assertEqual(cv.utils.testOverloadResolution(val, point=point),
|
||||
'overload (int={}, point=(x={}, y={}))'.format(val, *point),
|
||||
"Can't select first overload if one of the arguments are provided as keyword")
|
||||
|
||||
self.assertEqual(cv.utils.testOverloadResolution(val),
|
||||
'overload (int={}, point=(x=42, y=24))'.format(val),
|
||||
"Can't select first overload if one of the arguments has default value")
|
||||
|
||||
rect = (1, 5, 10, 23)
|
||||
self.assertEqual(cv.utils.testOverloadResolution(rect),
|
||||
'overload (rect=(x={}, y={}, w={}, h={}))'.format(*rect),
|
||||
"Can't select second overload if all arguments are provided")
|
||||
|
||||
def test_overload_resolution_fails(self):
|
||||
def test_overload_resolution(msg, *args, **kwargs):
|
||||
no_exception_msg = 'Overload resolution failed without any exception for: "{}"'.format(msg)
|
||||
wrong_exception_msg = 'Overload resolution failed with wrong exception type for: "{}"'.format(msg)
|
||||
with self.assertRaises((cv.error, Exception), msg=no_exception_msg) as cm:
|
||||
cv.utils.testOverloadResolution(*args, **kwargs)
|
||||
self.assertEqual(type(cm.exception), cv.error, wrong_exception_msg)
|
||||
|
||||
test_overload_resolution('wrong second arg type (keyword arg)', 5, point=(1, 2, 3))
|
||||
test_overload_resolution('wrong second arg type', 5, 2)
|
||||
test_overload_resolution('wrong first arg', 3.4, (12, 21))
|
||||
# FIXIT: test_overload_resolution('wrong first arg, no second arg', 4.5)
|
||||
test_overload_resolution('wrong args number for first overload', 3, (12, 21), 123)
|
||||
test_overload_resolution('wrong args number for second overload', (3, 12, 12, 1), (12, 21))
|
||||
# One of the common problems
|
||||
test_overload_resolution('rect with float coordinates', (4.5, 4, 2, 1))
|
||||
test_overload_resolution('rect with wrong number of coordinates', (4, 4, 1))
|
||||
|
||||
|
||||
class Arguments(NewOpenCVTests):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user