Skip to content

Commit

Permalink
Extend test_abc to include abstract properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau committed Sep 25, 2021
1 parent 6bd22e2 commit feb76b5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,11 @@ def some_classmethod(cls):
def some_staticmethod():
"""A staticmethod"""

@property
@abc.abstractmethod
def some_property():
"""A property"""

class ConcreteClass(AbstractClass):
def some_method(self):
return 'it works!'
Expand All @@ -1197,6 +1202,10 @@ def some_classmethod(cls):
def some_staticmethod():
return 'it works!'

@property
def some_property(self):
return 'it works!'

# This abstract class is locally defined so we can safely register
# tuple in it to verify the unpickled class also register tuple.
AbstractClass.register(tuple)
Expand All @@ -1218,6 +1227,9 @@ def some_staticmethod():

self.assertEqual(depickled_class().some_staticmethod(), 'it works!')
self.assertEqual(depickled_instance.some_staticmethod(), 'it works!')

self.assertEqual(depickled_class().some_property, 'it works!')
self.assertEqual(depickled_instance.some_property, 'it works!')
self.assertRaises(TypeError, depickled_base)

class DepickledBaseSubclass(depickled_base):
Expand All @@ -1233,6 +1245,10 @@ def some_classmethod(cls):
def some_staticmethod():
return 'it works for realz!'

@property
def some_property():
return 'it works for realz!'

self.assertEqual(DepickledBaseSubclass().some_method(),
'it works for realz!')

Expand Down Expand Up @@ -1261,7 +1277,7 @@ def some_staticmethod():

@abc.abstractproperty
def some_property(self):
"""A staticmethod"""
"""A property"""

class ConcreteClass(AbstractClass):
def some_method(self):
Expand Down

0 comments on commit feb76b5

Please sign in to comment.