Skip to content

Conversation

@dcermak
Copy link
Owner

@dcermak dcermak commented Jul 19, 2024

No description provided.

@codecov
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.77%. Comparing base (a465c0f) to head (1336897).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #216      +/-   ##
==========================================
+ Coverage   96.36%   96.77%   +0.40%     
==========================================
  Files           9        9              
  Lines        1101     1178      +77     
  Branches      164      168       +4     
==========================================
+ Hits         1061     1140      +79     
+ Misses         25       23       -2     
  Partials       15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dcermak dcermak force-pushed the inherit-marks branch 4 times, most recently from 5c3f7e4 to bdb8375 Compare July 23, 2024 13:27
@dcermak dcermak changed the title WIP: add as_pytest_param property to ContainerBaseABC Make Container, DerivedContainer & Pod inherit from ParameterSet Jul 23, 2024
@dcermak dcermak force-pushed the inherit-marks branch 5 times, most recently from 1031d79 to 9404424 Compare December 27, 2024 20:29
@dcermak dcermak force-pushed the inherit-marks branch 2 times, most recently from 89b9016 to 93bb2e4 Compare January 16, 2025 10:13
@dcermak dcermak force-pushed the inherit-marks branch 2 times, most recently from 1c0230f to de27761 Compare January 17, 2025 10:39
grisu48
grisu48 previously approved these changes Feb 10, 2025
1. you are now handling ``pytest.ParameterSet`` instance and have to unpack them
to access the underlying :py:class:`~pytest_container.container.Container`
Copy link

Choose a reason for hiding this comment

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

You are now handling (...) instance, and have to unpack them?

Copy link
Owner Author

Choose a reason for hiding this comment

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

the issue is this: let's say you are creating a TW container image:

TW = Container(url="registry.opensuse.org/opensuse/tumbleweed")

and now you want to wrap it in a pytest.param(), then you'd usually do this:

TW = pytest.param(
    Container(url="registry.opensuse.org/opensuse/tumbleweed"),
    marks=[pytest.mark.tumbleweed],
)

But now the TW object is no longer an instance of the Container class. If you now want to get any attribute, you have to call:

TW.values[0].url

The whole point of this gynormous PR is, that Container is a ParameterSet itself, and you directly get TW.url, but it behaves like a ParameterSet as well

source/usage.rst Outdated
Comment on lines 475 to 476
2. :py:class:`~pytest_container.container.DerivedContainer` do not "inherit" the
marks from their base containers. This has proven to be a very annoying
limitation in practice.
Copy link

@dmpop dmpop Feb 27, 2025

Choose a reason for hiding this comment

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

Suggested change
2. :py:class:`~pytest_container.container.DerivedContainer` do not "inherit" the
marks from their base containers. This has proven to be a very annoying
limitation in practice.
2. :py:class:`~pytest_container.container.DerivedContainer` does not "inherit" the
marks from their base containers. This has proven to be a very annoying
limitation in practice.

"inherit"

Why is inherit in double quotes?

This has proven to be a very annoying limitation in practice.

Either explain why it's a limitation (without using subjective "Annoying"), or drop it altogether.

Copy link
Owner Author

Choose a reason for hiding this comment

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

"inherit"

Why inherit is in double quotes?

Because it is not classical class based inheritance as used in programming.

This has proven to be a very annoying limitation in practice.

Either explain why it's a limitation (without using subjective "Annoying"), or drop it altogether.

This is a rather specific BCI-Tests problem that we saw in practice. We often have a base image, e.g. bci/golang. And now we have multiple test with their own Container Images classes (e.g. due to different dockerfiles). But since the marks don't "carry over" or "inherit" we have to do this:

golang = pytest.param(Container(…args…), marks=pytest.mark.golang)
param1 = pytest.param(DerivedContainer(base=golang.param[0], containerfile="something"), marks=golang.marks)
param2= pytest.param(DerivedContainer(base=golang.param[0], containerfile="something else"), marks=golang.marks)
# and so on

with this PR, we can now just write:

golang = Container(…args…, marks=pytest.mark.golang)
param1 = DerivedContainer(base=golang, containerfile="something")
param2= DerivedContainer(base=golang, containerfile="something else")
# and so on

and the result is the same

@dcermak dcermak force-pushed the inherit-marks branch 4 times, most recently from 5e713b1 to 282787c Compare March 28, 2025 13:31
@dcermak dcermak force-pushed the inherit-marks branch 5 times, most recently from 9b1160a to fc1bc6b Compare June 30, 2025 11:38
dcermak and others added 6 commits June 30, 2025 17:13
We can't do anything about the number of instance attributes, because they are
mandated by the output of `podman container inspect`
pathlib.Path is automatically resolved to the local implementation by sphinx
autodoc, which then cannot be found by intersphinx.
It just takes time for no benefit
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.

4 participants