Skip to content

Commit

Permalink
Merge pull request #132 from jacebrowning/add-failing-test
Browse files Browse the repository at this point in the history
Add test for known future annotations failure
  • Loading branch information
jacebrowning committed Oct 1, 2019
2 parents cb7c5de + 5c15151 commit cabb5dc
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tests/test_custom_converters_future.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# pylint: disable=arguments-differ
# pylint: disable=arguments-differ,no-member

from __future__ import annotations # this breaks custom converter lookup

from datetime import datetime
from typing import Optional

import pytest

from datafiles import Missing, datafile
from datafiles import datafile

from .test_custom_converters import MyDateTime


@pytest.mark.flaky
def test_extension(expect):
@datafile("../tmp/sample.yml")
class Timestamp:
dt: MyDateTime
class MyObject:
value: MyDateTime

ts = Timestamp(MyDateTime(2019, 1, 29))
expect(ts.datafile.text) == "dt: '2019-01-29T00:00:00'\n"
x = MyObject(MyDateTime(2019, 1, 29))
expect(x.datafile.text) == "value: '2019-01-29T00:00:00'\n"

ts = Timestamp(Missing) # type: ignore
expect(ts.dt) == datetime(2019, 1, 29)

ts.datafile.text = "dt: '2019-01-11T00:00:00'\n"
expect(ts.dt.day) == 11
@pytest.mark.xfail(reason='https://github.com/jacebrowning/datafiles/issues/131')
def test_optional(expect):
@datafile("../tmp/sample.yml")
class MyObject:
value: Optional[int]

x = MyObject(42)
expect(x.datafile.text) == "value: 42'\n"

0 comments on commit cabb5dc

Please sign in to comment.