Skip to content

Commit

Permalink
fix crash when running with xdist plugin disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead authored Jun 20, 2024
1 parent 64176b0 commit de77f64
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions python_files/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,3 +902,14 @@ def send_post_request(
def pytest_xdist_auto_num_workers(config: pytest.Config) -> Generator[None, int, int]:
"""determine how many workers to use based on how many tests were selected in the test explorer"""
return min((yield), len(config.option.file_or_dir))

class DeferPlugin:
@pytest.hookimpl(wrapper=True)
def pytest_xdist_auto_num_workers(self, config: pytest.Config):
"""determine how many workers to use based on how many tests were selected in the test explorer"""
return min((yield), len(config.option.file_or_dir))

def pytest_plugin_registered(plugin, manager):
if manager.hasplugin("xdist") and not isinstance(plugin, DeferPlugin):
manager.register(DeferPlugin())

0 comments on commit de77f64

Please sign in to comment.