-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove hard coded test cases #3062
Changes from 5 commits
881536c
76948e9
3c09918
93e9124
b949107
0939736
b5f4b15
b0bb5bc
6e68ac1
5b8b6dd
cbe9f7a
3055d7d
c0bf362
601af8e
e8e3d61
670aa54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,38 +15,6 @@ | |
all_data_cases, | ||
) | ||
|
||
PY310_CASES: List[str] = [ | ||
"starred_for_target", | ||
"pattern_matching_simple", | ||
"pattern_matching_complex", | ||
"pattern_matching_extras", | ||
"pattern_matching_style", | ||
"pattern_matching_generic", | ||
"parenthesized_context_managers", | ||
] | ||
|
||
PY311_CASES: List[str] = [ | ||
"pep_654", | ||
"pep_654_style", | ||
] | ||
|
||
PREVIEW_CASES: List[str] = [ | ||
# string processing | ||
"cantfit", | ||
"comments7", | ||
"comments8", | ||
"long_strings", | ||
"long_strings__edge_case", | ||
"long_strings__regression", | ||
"percent_precedence", | ||
"remove_except_parens", | ||
"remove_for_brackets", | ||
"one_element_subscript", | ||
"remove_await_parens", | ||
"return_annotation_brackets", | ||
"docstring_preview", | ||
] | ||
|
||
SOURCES: List[str] = [ | ||
"src/black/__init__.py", | ||
"src/black/__main__.py", | ||
|
@@ -105,7 +73,7 @@ def test_simple_format(filename: str) -> None: | |
check_file(filename, DEFAULT_MODE) | ||
|
||
|
||
@pytest.mark.parametrize("filename", PREVIEW_CASES) | ||
@pytest.mark.parametrize("filename", all_data_cases("preview")) | ||
def test_preview_format(filename: str) -> None: | ||
check_file(filename, black.Mode(preview=True)) | ||
|
||
|
@@ -164,15 +132,16 @@ def test_remove_with_brackets() -> None: | |
) | ||
|
||
|
||
@pytest.mark.parametrize("filename", PY310_CASES) | ||
@pytest.mark.parametrize("filename", all_data_cases("py_310")) | ||
def test_python_310(filename: str) -> None: | ||
source, expected = read_data(filename) | ||
mode = black.Mode(target_versions={black.TargetVersion.PY310}) | ||
assert_format(source, expected, mode, minimum_version=(3, 10)) | ||
|
||
|
||
def test_python_310_without_target_version() -> None: | ||
source, expected = read_data("pattern_matching_simple") | ||
@pytest.mark.parametrize("filename", all_data_cases("py_310")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noting that this changed, but I guess it can't hurt to test all the cases! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that this is the right thing to do, because the test is not specific for "pattern_matching_simple" |
||
def test_python_310_without_target_version(filename: str) -> None: | ||
source, expected = read_data(filename) | ||
mode = black.Mode() | ||
assert_format(source, expected, mode, minimum_version=(3, 10)) | ||
|
||
|
@@ -186,7 +155,7 @@ def test_patma_invalid() -> None: | |
exc_info.match("Cannot parse: 10:11") | ||
|
||
|
||
@pytest.mark.parametrize("filename", PY311_CASES) | ||
@pytest.mark.parametrize("filename", all_data_cases("py_311")) | ||
def test_python_311(filename: str) -> None: | ||
source, expected = read_data(filename) | ||
mode = black.Mode(target_versions={black.TargetVersion.PY311}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also walk the source directories here and get all of the Python files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that the right thing to do is to add the following step/job to the CI process:
pip install -e . black --check src
This should not be a unit test in my opinion, but another step/job in the CI process.
If you want an example, see what I did for my tool Statue in the CI process.
In the end of the CI I added a step called "Run on self" that checks that the code of statue pass the static code analysis ran by statue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, it appears we only check each file with default params, so that would work. I don't have a strong preference for it being in tests or CI. Perhaps here before publishing test results, so that the whole version matrix is tested. Other opinions?