pydantic / bump-pydantic

Convert Pydantic from V1 to V2 ♻
MIT License
317 stars 24 forks source link

Read test cases from toml files #84

Closed cclauss closed 7 months ago

cclauss commented 1 year ago

Just a little experiment... I left the current tests in place while adding tests that are read in from a cases.toml file so we could see both approaches side-by-side. Feel free to close with unmerged commits.

Kludex commented 1 year ago

This is great! Thanks @cclauss :)

Do we want to keep helping? My idea would be for each toml to be a "project", and run bump-pydantic on each "project". This way we could separate the test cases by "projects".

cclauss commented 1 year ago

Sure... A few things to look at... -- EDIT: Merged in #88

% ruff --select="A" .

tests/integration/case.py:11:5: A003 Class attribute `input` is shadowing a Python builtin
tests/integration/case.py:13:5: A003 Class attribute `id` is shadowing a Python builtin
Found 2 errors.

% ruff --select="B" .

bump_pydantic/main.py:45:21: B008 Do not perform function call `Argument` in argument defaults
bump_pydantic/main.py:46:27: B008 Do not perform function call `Option` in argument defaults
bump_pydantic/main.py:47:22: B008 Do not perform function call `Option` in argument defaults
bump_pydantic/main.py:48:21: B008 Do not perform function call `Option` in argument defaults
Found 4 errors.

% ruff --select="PT" . # This is --fix able.

tests/unit/test_add_default_none.py:41:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual`
tests/unit/test_add_default_none.py:60:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual`
tests/unit/test_add_default_none.py:81:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual`
tests/unit/test_add_default_none.py:108:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual`
tests/unit/test_add_default_none.py:129:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual`
tests/unit/test_add_default_none.py:151:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual`
Found 6 errors.
[*] 6 potentially fixable with the --fix option.
Kludex commented 1 year ago

About the input and id, I don't mind changing it and enabling that rule.

About the B008, it needs to be ignored. That's how Typer works.

About the PT, I'm fine about adding it, and fixing with --fix.

cclauss commented 1 year ago

Ready for review.... I left the folder-in-folder thing in Python but the others are in toml.

Kludex commented 1 year ago

Hmmm... I want to have a way to have folders in the TOML, and have each toml to be a separate test case, so I can specify with pytest the one I want.

cclauss commented 1 year ago

pytest --capture=sys --showlocals -vvv tests/integration/test_cli.py runs in about 2 sec. so running individual toml files seems like overkill that might allow developers to overlook breakage in other tests.

I will reexamine folders-in-folders over the weekend.