This rule raises an issue when a function-scoped test uses the tmp_path_factory fixture instead of the tmp_path
fixture.
tmp_path provides an isolated directory for one test. tmp_path_factory is for session, module, or class-scoped fixtures
that share directories across tests.
Using the factory in a function-scoped test adds an unnecessary mktemp() call and obscures intent.
Choosing the session-scoped factory in function-scoped tests raises the cost of onboarding developers to the fixture graph.
Replace tmp_path_factory with tmp_path in function-scoped tests.
def test_file_operation(tmp_path_factory): # Noncompliant
# Unnecessary factory for function scope
temp_dir = tmp_path_factory.mktemp('data')
test_file = temp_dir / 'test.txt'
test_file.write_text('content')
assert test_file.read_text() == 'content'
def test_file_operation(tmp_path):
# Direct tmp_path for function scope
test_file = tmp_path / 'test.txt'
test_file.write_text('content')
assert test_file.read_text() == 'content'