コード例 #1
0
ファイル: test_model_py36.py プロジェクト: vyrzdev/serde
    def test___new___annotations_resolved(self):
        # Check that annotations that require resolving can be used.

        class NestedExample(Model):
            a = fields.Int()

        class Example(Model):
            a: int
            nested: NestedExample

        # The field attributes should not be present on the final class.
        assert not hasattr(Example, 'a')
        assert not hasattr(Example, 'nested')

        # But they should be in the `__fields__` attribute
        assert Example.__fields__.a == fields.Int()
        assert Example.__fields__.nested == fields.Nested(NestedExample)
コード例 #2
0
 class Package(Model):
     name = fields.Str(rename='packageName')
     version = fields.Nested(Version)
コード例 #3
0
ファイル: test_model.py プロジェクト: vyrzdev/serde
 class Example(Model):
     nested = fields.Nested(NestedExample)
コード例 #4
0
ファイル: test_model.py プロジェクト: vyrzdev/serde
        class Example(Model):
            class Meta:
                tag = Adjacent(tag='kind', content='data')

            nested = fields.Nested(NestedExample)
コード例 #5
0
ファイル: test_model.py プロジェクト: vyrzdev/serde
        class Example(Model):
            class Meta:
                tag = Internal(tag='kind')

            nested = fields.Nested(NestedExample)
コード例 #6
0
ファイル: test_model.py プロジェクト: vyrzdev/serde
        class Example(Model):
            class Meta:
                tag = External()

            nested = fields.Nested(NestedExample)