mirror of
https://github.com/PyCQA/flake8.git
synced 2026-06-29 08:40:45 +00:00
Preserve legacy API options in workers
This commit is contained in:
parent
ee03327c82
commit
4ae06799c3
6 changed files with 53 additions and 7 deletions
|
|
@ -13,3 +13,17 @@ def test_legacy_api(tmpdir):
|
|||
style_guide = legacy.get_style_guide()
|
||||
report = style_guide.check_files([t_py.strpath])
|
||||
assert report.total_errors == 1
|
||||
|
||||
|
||||
def test_legacy_api_parallel_checks_use_option_overrides(tmpdir):
|
||||
long_line = f"x = \"{'a' * 80}\"\n"
|
||||
assert len(long_line.rstrip()) == 86
|
||||
|
||||
file1 = tmpdir.join("file1.py")
|
||||
file1.write(long_line)
|
||||
file2 = tmpdir.join("file2.py")
|
||||
file2.write(long_line)
|
||||
|
||||
style_guide = legacy.get_style_guide(max_line_length=88)
|
||||
report = style_guide.check_files([file1.strpath, file2.strpath])
|
||||
assert report.total_errors == 0
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ def test_acquire_when_multiprocessing_pool_can_initialize():
|
|||
with mock.patch("multiprocessing.Pool") as pool:
|
||||
result = checker._try_initialize_processpool(2, [])
|
||||
|
||||
pool.assert_called_once_with(2, checker._mp_init, initargs=([],))
|
||||
pool.assert_called_once_with(2, checker._mp_init, initargs=([], None))
|
||||
assert result is pool.return_value
|
||||
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ def test_acquire_when_multiprocessing_pool_can_not_initialize():
|
|||
with mock.patch("multiprocessing.Pool", side_effect=ImportError) as pool:
|
||||
result = checker._try_initialize_processpool(2, [])
|
||||
|
||||
pool.assert_called_once_with(2, checker._mp_init, initargs=([],))
|
||||
pool.assert_called_once_with(2, checker._mp_init, initargs=([], None))
|
||||
assert result is None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,17 @@ def test_multiprocessing_cpu_count_not_implemented():
|
|||
assert manager.jobs == 0
|
||||
|
||||
|
||||
def test_mp_init_applies_option_overrides():
|
||||
checker._mp = None
|
||||
try:
|
||||
checker._mp_init([], {"max_line_length": 88})
|
||||
assert checker._mp is not None
|
||||
_, options = checker._mp
|
||||
assert options.max_line_length == 88
|
||||
finally:
|
||||
checker._mp = None
|
||||
|
||||
|
||||
def test_jobs_count_limited_to_file_count():
|
||||
style_guide = style_guide_mock()
|
||||
style_guide.options.jobs = JobsArgument("4")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue