mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-03 11:56:52 +00:00
add integration test for off_by_default plugin
This commit is contained in:
parent
c3ab1fcfb2
commit
fa8ac82ee2
1 changed files with 28 additions and 0 deletions
|
|
@ -79,6 +79,10 @@ class AlwaysErrors:
|
|||
yield 1, 0, "ABC123 error", type(self)
|
||||
|
||||
|
||||
class AlwaysErrorsDisabled(AlwaysErrors):
|
||||
off_by_default = True
|
||||
|
||||
|
||||
def test_plugin_gets_enabled_by_default(tmp_path, capsys):
|
||||
cfg_s = f"""\
|
||||
[flake8:local-plugins]
|
||||
|
|
@ -95,3 +99,27 @@ extension =
|
|||
out, err = capsys.readouterr()
|
||||
assert out == f"{t_py}:1:1: ABC123 error\n"
|
||||
assert err == ""
|
||||
|
||||
|
||||
def test_plugin_off_by_default(tmp_path, capsys):
|
||||
cfg_s = f"""\
|
||||
[flake8:local-plugins]
|
||||
extension =
|
||||
ABC = {AlwaysErrorsDisabled.__module__}:{AlwaysErrorsDisabled.__name__}
|
||||
"""
|
||||
cfg = tmp_path.joinpath("tox.ini")
|
||||
cfg.write_text(cfg_s)
|
||||
|
||||
t_py = tmp_path.joinpath("t.py")
|
||||
t_py.touch()
|
||||
|
||||
cmd = (str(t_py), "--config", str(cfg))
|
||||
|
||||
assert main(cmd) == 0
|
||||
out, err = capsys.readouterr()
|
||||
assert out == err == ""
|
||||
|
||||
assert main((*cmd, "--enable-extension=ABC")) == 1
|
||||
out, err = capsys.readouterr()
|
||||
assert out == f"{t_py}:1:1: ABC123 error\n"
|
||||
assert err == ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue