black/tests
Antonio Ossa-Guerra d97b7898b3
Remove whitespaces of whitespace-only files (#3348)
Currently, empty and whitespace-only (with or without newlines) are
not modified. In some discussions (issues and pull requests) consensus
was to reformat whitespace-only files to empty or single-character
files, preserving line endings when possible. With that said, this
commit introduces the following behaviors:

* Empty files are left as is
* Whitespace-only files (no newline) reformat into empty files
* Whitespace-only files (1 or more newlines) reformat into a single
newline character

To implement these changes, we moved the initial check at
`format_file_contents` that raises `NothingChanged` if the source
(with no whitespaces) is an empty string. In the case of *.ipynb
files, `format_ipynb_string` checks a similar condition and removed
whitespaces. In the case of Python files, `format_str_once` includes a
check on the output that returns the correct newline character if
possible or an empty string otherwise.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2022-11-11 20:05:36 -05:00
..
data Remove whitespaces of whitespace-only files (#3348) 2022-11-11 20:05:36 -05:00
__init__.py Remove deprecated use of 'setup.py test' (#1275) 2020-05-08 06:23:50 -07:00
conftest.py Use optional tests for "no_python2" to simplify local testing (#2203) 2021-05-07 15:03:13 +02:00
empty.toml Add --target-version option to allow users to choose targeted Python versions (#618) 2019-02-06 18:43:50 -08:00
optional.py Use strict mypy checking (#3222) 2022-08-30 20:46:46 -07:00
test_black.py Remove whitespaces of whitespace-only files (#3348) 2022-11-11 20:05:36 -05:00
test_blackd.py Add option to skip the first line of source code (#3299) 2022-10-06 15:17:32 -07:00
test_format.py Strip trailing commas in subscripts with -C (#3209) 2022-08-13 06:41:34 -07:00
test_ipynb.py Reformat codebase with isort 2022-07-27 17:19:28 -04:00
test_no_ipynb.py Reformat codebase with isort 2022-07-27 17:19:28 -04:00
test_trans.py Reformat codebase with isort 2022-07-27 17:19:28 -04:00
test.toml Add support for custom python cell magics (#2744) 2022-01-20 16:45:28 -08:00
util.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00