Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
def pytest_addoption(parser):
parser.addoption(
"--force-log-cli",
action="store_true",
help="Force enable log_cli even when xdist is active",
)


def pytest_configure(config):
# Detect if xdist (parallel execution) is active
xdist_active = hasattr(config, "workerinput") or config.pluginmanager.hasplugin(
"xdist"
)


def pytest_addoption(parser):
parser.addoption(
"--force-log-cli",
action="store_true",
help="Force enable log_cli even when xdist is active",
)


def pytest_configure(config):
# Detect if xdist (parallel execution) is active
xdist_active = hasattr(config, "workerinput") or config.pluginmanager.hasplugin(
"xdist"
)

if not xdist_active or config.getoption("--force-log-cli"):
# Normal run (no xdist): enable live logs
config.option.log_cli = True
config.option.log_cli_level = "INFO"
else:
# xdist active: disable live logs so we get the 'dots' progress
config.option.log_cli = False

if not xdist_active or config.getoption("--force-log-cli"):
# Normal run (no xdist): enable live logs
config.option.log_cli = True
config.option.log_cli_level = "INFO"
else:
# xdist active: disable live logs so we get the 'dots' progress
config.option.log_cli = False
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
log_cli_level = INFO
addopts = -ra
11 changes: 11 additions & 0 deletions test_sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import time


def test_example_1():
time.sleep(0.5)
assert 1 == 1


def test_example_2():
time.sleep(0.5)
assert 2 == 2