Skip to content

[Bug]: test_constraint_logged_when_present fails unless --log-level=DEBUG is passed to pytest #1274

Description

@booxter

Environment

  • Fromager version: 0.91
  • Python version: 3.14
  • OS / architecture: Darwin
  • Container or local: local

Bug description

Expected behavior:

Tests pass without log level forced.

Actual behavior:

They fail.

=================================== FAILURES ===================================
__________ TestPhasePrepareSource.test_constraint_logged_when_present __________
[gw7] darwin -- Python 3.14.6 /nix/store/0788rbnl2p558jnyjlm2s2f9r5sxpq3h-python3-3.1
4.6/bin/python3.14

self = <test_bootstrapper_iterative.TestPhasePrepareSource object at 0x10ddf0290>
tmp_context = <fromager.context.WorkContext object at 0x10e621f90>
caplog = <_pytest.logging.LogCaptureFixture object at 0x10e684550>

    def test_constraint_logged_when_present(
        self, tmp_context: WorkContext, caplog: pytest.LogCaptureFixture
    ) -> None:
        """Constraint presence is logged without affecting phase advancement."""
        bt = bootstrapper.Bootstrapper(tmp_context)
        item = _make_build_item(phase=BootstrapPhase.PREPARE_SOURCE)
    
        sdist_root = tmp_context.work_dir / "testpkg-1.0" / "testpkg-1.0"
        mock_env = Mock()
        item.bg_future = _make_resolved_future(
            PreparedSourceData(sdist_root_dir=sdist_root)
        )
    
        with (
            patch.object(
                tmp_context.constraints,
                "get_constraint",
                return_value=Requirement("testpkg>=1.0"),
            ),
            patch(
                "fromager.build_environment.BuildEnvironment",
                return_value=mock_env,
            ),
            patch(
                "fromager.dependencies.get_build_system_dependencies",
                return_value=set(),
            ),
            patch.object(bt, "create_unresolved_work_items", return_value=[]),
        ):
            result = item.run(bt)
    
        assert isinstance(result[0], PrepareBuild)
>       assert "matches constraint" in caplog.text
E       AssertionError: assert 'matches constraint' in ''
E        +  where '' = <_pytest.logging.LogCaptureFixture object at 0x10e684550>.text

tests/test_bootstrapper_iterative.py:1318: AssertionError
=========================== short test summary info ============================
FAILED tests/test_bootstrapper_iterative.py::TestPhasePrepareSource::test_constraint_
logged_when_present - AssertionError: assert 'matches constraint' in ''
================== 1 failed, 862 passed, 4 skipped in 13.93s ===================

Steps to reproduce / logs:

Run test suite without --log-level=DEBUG passed to pytest.

Note: This is a re-iteration of #1092 now in a different test case. I think a durable fix would include not only a fix to this test case but also removing the --log-level=DEBUG option from CI runner script so that the next time a test case fogets to set the right log level, developers get a red signal from CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions