1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

fix: add _ suffix to properties having reserved keyword names

This commit is contained in:
Vadim Levin
2022-12-13 20:24:57 +03:00
parent c2ecbc76ce
commit 3f5f09e730
3 changed files with 39 additions and 4 deletions
+17
View File
@@ -119,6 +119,23 @@ class Bindings(NewOpenCVTests):
test_overload_resolution('rect with float coordinates', (4.5, 4, 2, 1))
test_overload_resolution('rect with wrong number of coordinates', (4, 4, 1))
def test_properties_with_reserved_keywords_names_are_transformed(self):
obj = cv.utils.ClassWithKeywordProperties(except_arg=23)
self.assertTrue(hasattr(obj, "lambda_"),
msg="Class doesn't have RW property with converted name")
try:
obj.lambda_ = 32
except Exception as e:
self.fail("Failed to set value to RW property. Error: {}".format(e))
self.assertTrue(hasattr(obj, "except_"),
msg="Class doesn't have readonly property with converted name")
self.assertEqual(obj.except_, 23,
msg="Can't access readonly property value")
with self.assertRaises(AttributeError):
obj.except_ = 32
class Arguments(NewOpenCVTests):