Skip to content

fix: Add [test] extra into options and include tests/ dir in package#656

Merged
alisonlhart merged 1 commit intoansible:mainfrom
alisonlhart:fix/package-tests-integration
Jan 7, 2026
Merged

fix: Add [test] extra into options and include tests/ dir in package#656
alisonlhart merged 1 commit intoansible:mainfrom
alisonlhart:fix/package-tests-integration

Conversation

@alisonlhart
Copy link
Copy Markdown
Contributor

@alisonlhart alisonlhart commented Jan 7, 2026

Closes: AAP-52688

Description

Moves the tests/ dir inside the source directory and adds [tests] extra to only include test dependencies when needed.

With tests included, we can run integration tests anywhere the package is installed.

This will allow us to run integration tests downstream directly from the package during container build.

Other changes

Has the server_url fixture self-start instead of requiring the --include-server flag, allowing us to start the server without the flag if necessary.

Reasoning

When running tests via pytest --pyargs ansible_dev_tools.tests... (from an installed package), pytest's hook execution order is:

  1. pytest_sessionstart fires before package discovery
  2. Package is loaded during test collection after hooks run
  3. Our conftest.py (with the server startup logic) isn't loaded until step 2

So even if we had a --include-server flag, by the time pytest loads our conftest that registers the flag and starts the server, pytest_sessionstart has already finished.

The solution: Make the server_url fixture self-starting:

  • When running from source: pytest_sessionstart hook fires first, starts server, fixture detects it's running
  • When running from installed package: Hook fires before conftest loads (no-op), fixture starts server itself

This allows the same tests to work both from source and from an installed package without any manual server startup.

@alisonlhart alisonlhart requested a review from a team as a code owner January 7, 2026 17:36
@alisonlhart alisonlhart added the fix label Jan 7, 2026
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
@alisonlhart alisonlhart marked this pull request as draft January 7, 2026 17:38
@alisonlhart alisonlhart force-pushed the fix/package-tests-integration branch from a16146d to dbbf53b Compare January 7, 2026 17:45
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
@alisonlhart alisonlhart force-pushed the fix/package-tests-integration branch from dbbf53b to 0a1f1c3 Compare January 7, 2026 17:55
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
@alisonlhart alisonlhart force-pushed the fix/package-tests-integration branch from 0a1f1c3 to 20429a6 Compare January 7, 2026 18:26
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
@alisonlhart alisonlhart force-pushed the fix/package-tests-integration branch from 20429a6 to 1e3be83 Compare January 7, 2026 18:38
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
@alisonlhart alisonlhart marked this pull request as ready for review January 7, 2026 18:39
@alisonlhart alisonlhart changed the title fix: Add [tests] extra into options and include tests/ dir in package fix: Add [test] extra into options and include tests/ dir in package Jan 7, 2026
@alisonlhart alisonlhart force-pushed the fix/package-tests-integration branch from 1e3be83 to e130d35 Compare January 7, 2026 20:43
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
@alisonlhart alisonlhart force-pushed the fix/package-tests-integration branch from e130d35 to 0a1ae44 Compare January 7, 2026 20:49
@github-actions github-actions bot added fix and removed fix labels Jan 7, 2026
Copy link
Copy Markdown
Contributor

@cidrblock cidrblock left a comment

Choose a reason for hiding this comment

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

nice, can't wait to see it in action

@alisonlhart alisonlhart merged commit d6e63ad into ansible:main Jan 7, 2026
27 checks passed
@github-project-automation github-project-automation bot moved this from Review to Done in 🧰 devtools project board Jan 7, 2026
@alisonlhart alisonlhart deleted the fix/package-tests-integration branch January 8, 2026 16:09
renovate bot added a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 9, 2026
sdwilsh pushed a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants