Skip to content

Commit

Permalink
Merge pull request #478 from drdavella/fix-custom-type-inheritance
Browse files Browse the repository at this point in the history
Fix CustomType inheritance in custom type used in test
  • Loading branch information
drdavella authored Mar 27, 2018
2 parents c457a53 + f1f1882 commit a5507fb
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions asdf/tests/test_asdftypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,13 @@ def test_versioned_writing():

versioning.supported_versions.append(versioning.AsdfVersion('42.0.0'))

# Currently this class cannot inherit directly from ComplexType because if
# it does it pollutes ASDF's built-in extension and causes later tests that
# rely on ComplexType to fail. However, if CustomType is ever implemented
# as an abstract base class, then it will be possible to use it as a mix-in
# and also inherit from ComplexType. This means the only method/attribute
# that will need to be explicitly defined will be 'version'.
class FancyComplexType(asdftypes.CustomType):
name = ComplexType.name
class FancyComplexType(ComplexType, asdftypes.CustomType):
version = (42, 0, 0)
types = ComplexType.types

@classmethod
def to_tree(cls, node, ctx):
return ComplexType.to_tree(node, ctx)

@classmethod
def from_tree(cls, tree, ctx):
return ComplexType.from_tree(tree, ctx)
# This is a sanity check to ensure that the custom FancyComplexType does
# not get added to ASDF's built-in extension, since this would cause any
# subsequent tests that rely on ComplexType to fail.
assert not issubclass(FancyComplexType, asdftypes.AsdfTypeMeta)

class FancyComplexExtension(object):
@property
Expand Down

0 comments on commit a5507fb

Please sign in to comment.