MCPcopy Index your code
hub / github.com/codespell-project/codespell / test_bad_glob

Function test_bad_glob

codespell_lib/tests/test_basic.py:213–233  ·  view source on GitHub ↗
(
    tmp_path: Path,
    capsys: pytest.CaptureFixture[str],
)

Source from the content-addressed store, hash-verified

211
212
213def test_bad_glob(
214 tmp_path: Path,
215 capsys: pytest.CaptureFixture[str],
216) -> None:
217 # disregard invalid globs, properly handle escaped globs
218 g = tmp_path / "glob"
219 g.mkdir()
220 fname = g / "[b-a].txt"
221 fname.write_text("abandonned\n")
222 assert cs.main(g) == 1
223 # bad glob is invalid
224 result = cs.main("--skip", "[b-a].txt", g, std=True)
225 assert isinstance(result, tuple)
226 code, _, stderr = result
227 if sys.hexversion < 0x030A05F0: # Python < 3.10.5 raises re.error
228 assert code == EX_USAGE, "invalid glob"
229 assert "invalid glob" in stderr
230 else: # Python >= 3.10.5 does not match
231 assert code == 1
232 # properly escaped glob is valid, and matches glob-like file name
233 assert cs.main("--skip", "[[]b-a[]].txt", g) == 0
234
235
236@pytest.mark.skipif(sys.platform != "linux", reason="Only supported on Linux")

Callers

nothing calls this directly

Calls 1

mainMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…