Skip to content

Migrate more test examples to use pytest parametrization#1278

Merged
lrandersson merged 9 commits into
conda:mainfrom
lrandersson:dev-ra-838-3
Jul 8, 2026
Merged

Migrate more test examples to use pytest parametrization#1278
lrandersson merged 9 commits into
conda:mainfrom
lrandersson:dev-ra-838-3

Conversation

@lrandersson

@lrandersson lrandersson commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

This is a follow-up of #1266, since that PR added the foundation, this PR migrates about half of the tests to the new layout (to simplify review). I am planning to a third (last) PR with the remaining tests.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@lrandersson lrandersson self-assigned this Jul 1, 2026
@github-project-automation github-project-automation Bot moved this to 🆕 New in 🔎 Review Jul 1, 2026
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jul 1, 2026
Comment thread tests/test_examples.py
return Path("~").expanduser() / calculate_install_dir(input_dir / config_filename)
elif installer.suffix == ".msi":
return calculate_msi_install_path(input_dir / config_filename)
elif short:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One of the examples reached maximum path length with the new pytest parametrization. pytest automatically creates unique tmp directories for each test parameter run (like /tmp/pytest-of-<username>/pytest-<run_number>/<test_module_name>/<test_function_name><[parameter_id]>/), because of this, one of the examples reached the max path limit (it was very close to the limit already). Therefore this new arg short simply forces it into a shorter name.

@lrandersson lrandersson marked this pull request as ready for review July 8, 2026 12:41
@lrandersson lrandersson requested a review from a team as a code owner July 8, 2026 12:41
Comment thread examples/azure_signtool/construct.yaml Outdated
name: Signed_AzureSignTool
version: 1.0.0
installer_type: [exe, msi]
installer_type: [exe, msi] # [win]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The entire installer should only run on Windows, so I don't think we need to add that selector.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Originally I did not add the selector but I found a bug which resulted in me adding it. Without # [win] the regex matches [exe, msi] as a selector because the regex looks for any [...] at the end of a line. It tries to evaluate exe, msi as a Python expression, which fails because exe and msi aren't defined variables.
The # [win] selector is needed to prevent the YAML list value from being misinterpreted as a platform selector.

I am planning to fix it but I propose to do it in a separate PR to minimize the changes in this PR since it's not a new bug.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then why not format it as YAML?

installer_type:
  - exe
  - msi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call, I was so locked in on the formats already in our code-base and forgot this was an option. See 3e648b4.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually I think the selector is needed:

INTERNALERROR> SystemExit: Error: invalid installer type 'exe' for linux; allowed: sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is happening during the unit tests. I think there is something going on during the import step when the tests are collected that the selector may be masking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did a little more changes, with some minor refactoring to be able to filter out this scenario fc7df2e. The refactoring allows installer_types_for_example() to handle platform-incompatible examples by catching InvalidInstallerTypeError instead of SystemExit, so tests are properly skipped without needing platform specific selectors in the YAML file or manual skipif decorators.

@github-project-automation github-project-automation Bot moved this from 🆕 New to ✅ Approved in 🔎 Review Jul 8, 2026
@lrandersson lrandersson merged commit 4cd5e95 into conda:main Jul 8, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Status: 🏁 Done

Development

Successfully merging this pull request may close these issues.

3 participants