Skip to content

Commit 267388d

Browse files
committed
Switched logic to be in conftest to apply an isolated flag to any test using capsys
1 parent e313729 commit 267388d

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎tests/conftest.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ def pytest_collection_modifyitems(items, *args, **kwargs):
216216
if marker.name in test_type_markers:
217217
break
218218
else:
219-
# if no test type marker is found, assume fast test
220-
item.add_marker("fast")
219+
# If no test type marker is found, assume it is a fast or isolated test.
220+
if "capsys" in item.fixturenames:
221+
# capsys is not threadsafe, so the test must be isolated.
222+
item.add_marker("isolated")
223+
else:
224+
item.add_marker("fast")
221225

222226

223227
# Ignore all local config files

‎tests/core/test_context.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ def test_override_builtin_audit_blocking_mode():
13091309
with pytest.raises(SQLMeshError):
13101310
context.plan(auto_apply=True, no_prompts=True)
13111311

1312-
@pytest.mark.isolated
1312+
13131313
def test_python_model_empty_df_raises(sushi_context, capsys):
13141314
sushi_context.console = create_console()
13151315

@@ -2789,7 +2789,6 @@ def test_catalog_name_needs_to_be_quoted():
27892789
assert context.fetchdf('select * from "foo--bar".db.x').to_dict() == {"c": {0: 1}}
27902790

27912791

2792-
@pytest.mark.isolated
27932792
def test_plan_runs_audits_on_dev_previews(sushi_context: Context, capsys, caplog):
27942793
sushi_context.console = create_console()
27952794

‎tests/core/test_snapshot_evaluator.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def x(evaluator, y=None) -> None:
246246
**common_kwargs,
247247
)
248248

249-
@pytest.mark.isolated
249+
250250
def test_runtime_stages(capsys, mocker, adapter_mock, make_snapshot):
251251
evaluator = SnapshotEvaluator(adapter_mock)
252252

‎tests/core/test_table_diff.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def capture_console_output(method_name: str, **kwargs) -> str:
4545
finally:
4646
console_output.close()
4747

48-
@pytest.mark.isolated
48+
4949
def test_data_diff(sushi_context_fixed_date, capsys, caplog):
5050
model = sushi_context_fixed_date.models['"memory"."sushi"."customer_revenue_by_day"']
5151

0 commit comments

Comments
 (0)