/ dev / clint / tests / rules / test_unnamed_thread_pool.py
test_unnamed_thread_pool.py
 1  from pathlib import Path
 2  
 3  from clint.config import Config
 4  from clint.index import SymbolIndex
 5  from clint.linter import Position, Range, lint_file
 6  from clint.rules import UnnamedThreadPool
 7  
 8  
 9  def test_thread_pool_executor(index: SymbolIndex) -> None:
10      code = """
11  from concurrent.futures import ThreadPoolExecutor
12  
13  # Bad
14  ThreadPoolExecutor()
15  
16  # Good
17  ThreadPoolExecutor(thread_name_prefix="worker")
18  """
19      config = Config(select={UnnamedThreadPool.name})
20      results = lint_file(Path("test.py"), code, config, index)
21      assert len(results) == 1
22      assert isinstance(results[0].rule, UnnamedThreadPool)
23      assert results[0].range == Range(Position(4, 0))