Skip to content

Conversation

@rwgk
Copy link
Collaborator

@rwgk rwgk commented Nov 25, 2025

Add --showlocals option to pytest configurations across all projects to ensure consistent behavior when displaying local variables in test failures.

pytest does not merge addopts across configuration files - it uses the first configuration found. When running pytest from a subdirectory, the local pytest.ini or pyproject.toml takes precedence over the root config. To ensure --showlocals applies regardless of where pytest is invoked, we add it to each project's configuration:

  • Root pytest.ini: applies when running from repository root
  • cuda_core/pytest.ini: applies when running from cuda_core directory
  • cuda_bindings/pyproject.toml: appended to existing addopts
  • cuda_pathfinder/pyproject.toml: added new pytest.ini_options section

This approach ensures uniform pytest behavior across all projects while maintaining the ability to run tests from any directory.

Example behavior with --showlocals:

    def test_a_minus_b():
        a = float('inf')
        b = 1
        c = a - b
>       assert math.isfinite(c)
E       assert False
E        +  where False = <built-in function isfinite>(inf)
E        +    where <built-in function isfinite> = math.isfinite

a          = inf
b          = 1
c          = inf

tests/test_demo.py:5: AssertionError

Add '--showlocals' option to pytest configurations across all projects
to ensure consistent behavior when displaying local variables in test
failures.

Pytest does not merge addopts across configuration files - it uses the
first configuration found. When running pytest from a subdirectory, the
local pytest.ini or pyproject.toml takes precedence over the root config.
To ensure --showlocals applies regardless of where pytest is invoked, we
add it to each project's configuration:

- Root pytest.ini: applies when running from repository root
- cuda_core/pytest.ini: applies when running from cuda_core directory
- cuda_bindings/pyproject.toml: appended to existing addopts
- cuda_pathfinder/pyproject.toml: added new pytest.ini_options section

This approach ensures uniform pytest behavior across all projects while
maintaining the ability to run tests from any directory.
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Nov 25, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rwgk
Copy link
Collaborator Author

rwgk commented Nov 25, 2025

/ok to test

@github-actions

This comment has been minimized.

@rwgk rwgk marked this pull request as ready for review November 25, 2025 16:03
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Nov 25, 2025

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rwgk rwgk requested a review from cpcloud November 25, 2025 16:03
Copy link
Contributor

@mdboom mdboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rwgk
Copy link
Collaborator Author

rwgk commented Dec 1, 2025

Thanks @mdboom!

@rwgk rwgk merged commit 4ab8404 into NVIDIA:main Dec 1, 2025
61 checks passed
@rwgk rwgk deleted the pytest_showlocals branch December 1, 2025 16:49
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Doc Preview CI
Preview removed because the pull request was closed or merged.

@leofang leofang added enhancement Any code-related improvements test Improvements or additions to tests cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module cuda.pathfinder Everything related to the cuda.pathfinder module P1 Medium priority - Should do labels Dec 1, 2025
@leofang leofang added this to the cuda-python 13-next, 12-next milestone Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module cuda.pathfinder Everything related to the cuda.pathfinder module enhancement Any code-related improvements P1 Medium priority - Should do test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants