Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest: DX - Support targeting specific tests using make pytest w/ PYTEST_TESTS #7681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

s373nZ
Copy link
Contributor

@s373nZ s373nZ commented Sep 19, 2024

This is a small PR intended to slightly improve developer experience. When running the Pytest integration testing suite locally using the command make pytest, the build system takes care of altering the local context variable PYTHONPATH to make sure contributed modules are accessible to the process. While this works great for running the entire test suite, oftentimes developers are concerned with repeatedly running a subset of the tests, the particular test relevant to the functionality they are working on, or some problematic tests which the suite reports failing.

Currently, in order to target specific tests for a pytest run, a developer might:

  1. Run make pytest
  2. Observe the output to discern and capture the computed value for PYTHONPATH
  3. Copy this value
  4. Export the value as a local PYTHONPATH variable
  5. Run pytest outside of the Makefile context and feeding in the targeted list of files and tests cases to the local command

This PR suggests supporting the pass-through of a variable named PYTEST_TESTS which defaults to tests/ and can be set in a similar fashion to PYTEST_PAR and PYTEST_OPTS. This would allow developers to skip a few steps in setting up their local environment for running pytest and enjoy some of the Makefile's sane defaults if desired. For example,

PYTEST_TESTS="tests/test_askrene.py::test_layers" make pytest

Certainly, experienced CLN developers already have more convenient workflows, so please let me know if there is a more accessible convention for this.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

Select tests by setting the `PYTEST_TESTS` environment variable.

Changelog-None
@s373nZ s373nZ force-pushed the make-pytest-support-target-tests branch from 356ec4c to 340385c Compare September 23, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant