Repository navigation
test(logger): remove redundant tests and parametrize duplicates in test_logger.py - #830
Merged
Merged
Conversation
Drop tests in test_logger.py that either assert nothing meaningful or are strict subsets of other tests (in this file, test_bt_json.py, test_id_gen.py, or test_span_components.py): - init dataset-id tests that never call init() - JSONAttachment tests that only check objects they just constructed - span.log binary/bad-key/large-document tests with near-empty assertions - duplicated attachment extraction, deep-copy identity, and upload-tracking tests - duplicate explicit-parent, otel flush, and dataset batch-size tests - async/thread tests that call span.link() directly, bypassing context Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ests - Collapse six sync/async BRAINTRUST_MAX_GENERATOR_ITEMS tests (limit 3, 0, -1) into one parametrized test using monkeypatch instead of manual env save/restore. The zero-limit case now also asserts no truncation warning, which the old tests missed. - Split the invalid-max-items test by sync/async via the same helper. - Parametrize test_traced_async_function over @Traced, @Traced(), and @Traced(name=...) instead of repeating the body three times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Replace nine _get_exporter/Experiment.export/Logger.export tests with one parametrized test over the ID-mode env vars, and add the case where BRAINTRUST_OTEL_COMPAT overrides BRAINTRUST_LEGACY_IDS. - Fold the flush_otel no-callback test into test_register_otel_flush_callback. - Use monkeypatch in reset_id_generator_state and the otel ID tests instead of manual os.environ save/restore; drop leftover debug prints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Replace seven model_dump metadata tests (span/logger/experiment log, logger/experiment log_feedback, dataset insert/update) with one parametrized test. - Merge the simple and nested circular-reference tests, and the NaN and Infinity tests, into single tests. - Replace four masking tests, each with its own hand-rolled recursive masking function (and leftover debug prints), with one parametrized test over logger, experiment, child span, and dataset sharing one masking function. It also checks that no unmasked value appears anywhere in the logged rows. - Drop the stale "This test currently FAILS" docstring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Convert the TestLogger TestCase methods to plain pytest functions. - Replace four load_prompt/load_parameters "version over environment" tests, each inlining a full response body, with one parametrized test that reuses _prompt_response/_parameters_response. - Collapse strict-mode template tests into present/missing parametrized tests sharing a single _test_prompt helper (which the structured-output test now uses too), and drop the render_mustache tests they subsume. - Merge the two transient-error cache fallback tests and assert the second request actually reached the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Replace the atexit enable/disable TestCase methods with one parametrized test, adding the explicit "false" case. - Collapse four bt-eval internal BTQL merge tests into one parametrized test using the monkeypatch fixture instead of a hand-built MonkeyPatch, and drop dead app_conn setup from the fetch forwarding test. - Parametrize the two proxy_conn base URL tests. - Use monkeypatch in the logged-out span link env var tests, and assert the full experiment link instead of three substrings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Merge span-name-matches-logged-data into the explicit-name test, drop the current_span().name test covered by the @Traced name test, and assert the inferred child span name's "func:file.py:line" format instead of non-empty. - Rename the noop span name test to match what it asserts. - Fold the emit_log log-level test into test_logger_log_level_helpers. - Rename test_nested_spans_with_export to describe the login regression it covers, and drop redundant local imports and unused variables. - Move the get_repo_info(None) test to test_gitutil.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fold test_logger_emit_log_enqueues_single_row into test_logger_emit_log_without_active_span (raw enqueue count and _is_merge). - Replace four str.format template tests and two t-string rendering tests with one parametrized test over level, message, and parameters, gating the t-string cases per-param on Python 3.14. Every case now asserts the full metadata, the log level, and that no span error field is set. - Add a small _t_string helper so t-string tests don't repeat importlib/templatelib boilerplate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Build test prompts with Prompt.from_prompt_data instead of a hand-rolled PromptSchema. - Test the inferred child span name by calling start_span from a user-named module, asserting the exact "user_fn:user_module.py:2" name instead of matching whatever pytest frame happens to be the caller. - Pass @Traced decorators and generator consumers as parametrize values instead of lambdas and string dispatch; add an expected_id column rather than deriving the id from the response shape. - Reduce reset_id_generator_state to the env clearing it actually does (the autouse conftest fixture already replaces the cached state), use it in the export format test, and drop checks already covered by test_id_gen.py, test_env.py, and redundant parametrize rows. - Remove a stray comment left by the deleted dataset-id tests and rename a misleading masking test column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleans up
py/src/braintrust/test_logger.pyby removing redundant and near-empty tests and parametrizing near-duplicates. Test-only change; no SDK code is modified.test_logger.py(one test moved totest_gitutil.py).What changed
initdataset-id tests that never calledinit()JSONAttachmenttests that only checked objects they had just builtspan.logbinary/bad-key tests that asserted only that a key existsid_genandspan_componentstests already covered intest_bt_json.py,test_id_gen.pyortest_span_components.pyMAX_GENERATOR_ITEMSlimits (sync/async × 3/0/-1)model_dumpmetadata across 7 logging APIsatexit,proxy_connemit_logstr.format/t-string template renderingTestLoggergrab-bag into plain pytest functions.os.environsave/restore (and a hand-builtpytest.MonkeyPatch()) with themonkeypatchfixture.test_get_repo_info_without_settings_returns_nonetotest_gitutil.py.Assertions that got stricter
user_fn:user_module.py:2) by callingstart_span()from a module that isn't underbraintrust.*. Before, the test only checked that the name wasn't empty.errorfield is set.BRAINTRUST_OTEL_COMPATtakes priority overBRAINTRUST_LEGACY_IDSfor the export format.Test plan
nox -s test_core: 926 passed, 69 skipped, 12 xfailed (main: 955 passed). Outsidetest_logger.py, the only difference is the test moved intotest_gitutil.py.test_logger.pypasses in 5 shuffled orders, and on Python 3.11 (t-string cases skip) as well as 3.14.logger.pyand confirmed the new tests fail.ruff,pre-commithooks,pylint --errors-only.🤖 Generated with Claude Code
Co-authored by StarfolkAI (@starfolkai)[bot]