@@ -386,3 +386,65 @@ class Impl failed to implement interface I:
386
386
- foo: 'function' is not a subtype of expected type 'classmethod'"""
387
387
)
388
388
assert expected == str (e .value )
389
+
390
+
391
+ def test_property ():
392
+
393
+ class I (Interface ):
394
+ @property
395
+ def foo (self ): # pragma: nocover
396
+ pass
397
+
398
+ class my_property (property ):
399
+ pass
400
+
401
+ class Impl (implements (I )):
402
+ @my_property
403
+ def foo (self ): # pragma: nocover
404
+ pass
405
+
406
+ with pytest .raises (IncompleteImplementation ) as e :
407
+ class Impl (implements (I )):
408
+ def foo (self ): # pragma: nocover
409
+ pass
410
+
411
+ expected = dedent (
412
+ """
413
+ class Impl failed to implement interface I:
414
+
415
+ The following methods of I were implemented with incorrect types:
416
+ - foo: 'function' is not a subtype of expected type 'property'"""
417
+ )
418
+ assert expected == str (e .value )
419
+
420
+ with pytest .raises (IncompleteImplementation ) as e :
421
+ class Impl (implements (I )):
422
+ @property
423
+ def foo (self , a , b ): # pragma: nocover
424
+ pass
425
+
426
+ expected = dedent (
427
+ """
428
+ class Impl failed to implement interface I:
429
+
430
+ The following methods of I were implemented with invalid signatures:
431
+ - foo(self, a, b) != foo(self)"""
432
+ )
433
+ assert expected == str (e .value )
434
+
435
+ with pytest .raises (IncompleteImplementation ) as e :
436
+ class Impl (implements (I )):
437
+ def foo (self , a , b ): # pragma: nocover
438
+ pass
439
+
440
+ expected = dedent (
441
+ """
442
+ class Impl failed to implement interface I:
443
+
444
+ The following methods of I were implemented with incorrect types:
445
+ - foo: 'function' is not a subtype of expected type 'property'
446
+
447
+ The following methods of I were implemented with invalid signatures:
448
+ - foo(self, a, b) != foo(self)"""
449
+ )
450
+ assert expected == str (e .value )
0 commit comments