-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from jacebrowning/add-failing-test
Add test for known future annotations failure
- Loading branch information
Showing
1 changed file
with
15 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |