SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
paths: - "tests/**/*.py"
pytest conventions
For the Python integration suite under tests/. Setup, running, and suite layout live in docs/contributing/tests/integration.md.
- No
_-prefixed helper functions in test modules — this is the rule that matters most. A reader must be able to see what a test does in its body alone, without chasing private helpers that scatter the meaning across the file. Inline the logic: an expression, a comprehension, a few repeated lines are all fine — repetition across tests is cheaper than indirection. When several tests genuinely share non-trivial setup or assertions, that is what fixtures are for — intests/fixtures/, see the next rule. A module-level_helper()is never the answer. - Fixtures live in
tests/fixtures/— never underintegration/tests/. Not in test modules, not in suiteconftest.pyfiles.tests/fixtures/is the shared library (auth, signoz, clickhouse, logs/metrics/traces seeding, …): reuse what's there before writing anything new; when a new fixture is genuinely needed, add it to the matchingtests/fixtures/module and register new modules intests/conftest.pypytest_plugins. The one exception: SigNoz-level fixtures in a suite'sconftest.py. A suite that needs its own SigNoz spun up with different envs (create_signoz/create_migratorwithenv_overrides+cache_key— e.g. basepath, metricreduction, querier_json_body) keeps that in itsconftest.py; that is always okay. - Fixture only when there is a lifecycle; otherwise a plain function. A fixture earns its indirection by owning setup/teardown (
yield+ cleanup —insert_metricstruncating on teardown) or by provisioning a resource (containers, SigNoz instances). A stateless action or lookup (create_saved_view,find_saved_view_by_name, wiping a resource list) is a plain importable function in the matchingtests/fixtures/module, takingsignoz/tokenas ordinary arguments — never wrap a plain callable in a fixture-factory just to injectsignoz. - Fixtures own their cleanup. When a test needs seeded state, put the seed + cleanup pair in a fixture (
yield, then tear down) so tests in the same suite don't interfere — the patterninsert_metricssets: yield a callable, truncate on teardown. - Fixture-factory over indirect parametrization. A fixture that yields a callable (e.g.
insert_metrics(metrics)) is clearer than@pytest.mark.parametrize(..., indirect=True)+request.param— the value is an explicit argument, not resolved by magic. - Skip at collection, not inside the test body. Use
pytest.param(..., marks=pytest.mark.skip(reason="…"))so a skipped case shows as SKIPPED-with-reason and short-circuits before its fixtures run (no environment spin-up for a test that won't execute). - Test config comes from explicit
--flags, not the environment. Wire configuration as pytest options declared intests/conftest.py(pytest_addoption— e.g.--sqlstore-provider,--clickhouse-version); do not addos.environfallbacks inside tests or fixtures. - snake_case parametrize ids.
ids=["fill_gaps", "fill_zero"], not camelCase. - Name suite files with the two-digit prefix (
NN_*.py).pyproject.tomlrestricts collection to[0-9][0-9]_*.py(plus the bootstrapsetup.py/run.py) — a file that doesn't match is silently never collected. - Always run pytest from
tests/.--import-mode=importlibis what allows same-basename files across suites (querier/01_logs.pyvsrawexportdata/01_logs.py), but it disables pytest's implicitsys.pathinjection —import fixturesonly resolves viapythonpath = ["."]from that rootdir. - After changing any
.pyfile, runmake py-fmtandmake py-lintfrom the repo root and fix what they report.