-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed pydantic integration and HasRepr
- Loading branch information
Showing
7 changed files
with
137 additions
and
18 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
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 |
---|---|---|
|
@@ -46,6 +46,7 @@ def test(session): | |
"time-machine", | ||
"mypy", | ||
"pyright", | ||
"pydantic", | ||
) | ||
|
||
cmd = [] | ||
|
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
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
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
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,15 +1,45 @@ | ||
from executing import Source | ||
|
||
from .example import Example | ||
from inline_snapshot import HasRepr | ||
from inline_snapshot import snapshot | ||
from inline_snapshot._change import Replace | ||
|
||
|
||
def test_diff_multiple_files(): | ||
def test_example(): | ||
|
||
Example( | ||
""" | ||
e = Example( | ||
{ | ||
"test_a.py": """ | ||
from inline_snapshot import snapshot | ||
def test_a(): | ||
assert 1==snapshot(2) | ||
""", | ||
).run_pytest( | ||
"test_b.py": "1+1", | ||
}, | ||
) | ||
|
||
e.run_pytest( | ||
"--inline-snapshot=create,fix", | ||
) | ||
|
||
e.run_inline( | ||
"fix", | ||
reported_flags=snapshot(["fix"]), | ||
changes=snapshot( | ||
[ | ||
Replace( | ||
flag="fix", | ||
source=HasRepr(Source, "<source test_a.py>"), | ||
node="Constant(value=2)", | ||
new_code="1", | ||
old_value=2, | ||
new_value=1, | ||
) | ||
] | ||
), | ||
).run_inline( | ||
"fix", | ||
changed_files=snapshot({}), | ||
) |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from .example import Example | ||
from inline_snapshot import snapshot | ||
|
||
|
||
def test_pydantic_repr(): | ||
|
||
Example( | ||
""" | ||
from pydantic import BaseModel | ||
from inline_snapshot import snapshot | ||
class M(BaseModel): | ||
size:int | ||
name:str | ||
age:int=4 | ||
def test_pydantic(): | ||
assert M(size=5,name="Tom")==snapshot() | ||
""" | ||
).run_inline( | ||
"create", | ||
changed_files=snapshot( | ||
{ | ||
"test_something.py": """\ | ||
from pydantic import BaseModel | ||
from inline_snapshot import snapshot | ||
class M(BaseModel): | ||
size:int | ||
name:str | ||
age:int=4 | ||
def test_pydantic(): | ||
assert M(size=5,name="Tom")==snapshot(M(name="Tom", size=5)) | ||
\ | ||
""" | ||
} | ||
), | ||
).run_inline() |