black/tests
Antonio Ossa-Guerra 18fb88486d
Fix false symlink detection claims in verbose output (#3385)
When trying to format a project from the outside, the verbose output
shows says that there are symbolic links that points outside of the
project, but displays the wrong project path, meaning that these
messages are false positives.

This bug is triggered when the command is executed from outside a
project on a folder inside it, causing an inconsistency between the
path to the detected project root and the relative path to the target
contents.

The fix is to normalize the target path using the project root before
processing the sources, which removes the presence of the incorrect
messages.

---

The test attemps to emulate the behavior of the CLI as closely as
posible by patching some `pathlib.Path` methods and passing certain
reference paths to the context object and `black.get_sources`.

Before the associated fix was introduced, this test failed because
some of the captured files reported the presence of a symlink due to
an incorrectly formated path. The test also asserts that only a single
file is reported as ignored, which is part of the expected behavior.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2023-01-18 21:38:27 -05:00
..
data Fix crash with walrus + await + with (#3473) 2023-01-17 22:25:05 -08: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 Fix false symlink detection claims in verbose output (#3385) 2023-01-18 21:38:27 -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 Fix two docstring crashes (#3451) 2023-01-16 12:26:03 -08:00
test_ipynb.py Reformat codebase with isort 2022-07-27 17:19:28 -04:00
test_no_ipynb.py make black[jupyter] installation cross-shell (#3394) 2022-12-10 11:49:33 -08: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 Check stability for both preview and non-preview styles (#3423) 2022-12-17 10:31:47 -08:00