@@ -40,29 +40,41 @@ Integration tests would be required for large changes (TBD).
4040
4141Run unit tests and get coverage report:
4242
43- ```
43+ ``` bash
4444pip install tox
4545tox -e coverage
4646```
4747
4848#### Advanced testing
4949
5050Always prefer to run ` tox ` directly, even when you want to run a specific test or scenario.
51- Instead of running ` pytest ` directly, you should run:
51+ Instead of running ` pytest ` directly, you should run it through tox :
5252
53- ```
53+ ``` bash
5454tox -e py -- podman/tests/integration/test_container_create.py -k test_container_directory_volume_mount
5555```
5656
57- If you'd like to test against a specific ` tox ` environment you can do:
57+ Pass pytest options after ` -- ` .
58+
59+ ##### Test against a specific python version
5860
59- ```
61+ If you'd like to test against a specific ` tox ` environment (like a specific python version) you can do:
62+
63+ ``` bash
6064tox -e py12 -- podman/tests/integration/test_container_create.py -k test_container_directory_volume_mount
6165```
6266
63- Pass pytest options after ` -- ` .
67+ Avaliable environments are specified under ` tox.envlist ` in ` tox.ini `
68+
69+ ##### Test against a specific podman version
70+
71+ By default, our test suite uses the podman version that's found in the path, i.e., the installed binary. If you want to use a specific version, or a custom build, pass it via the env variable.
72+
73+ ``` bash
74+ PODMAN_BINARY=/path/to/podman/bin tox -e py -- ...
75+ ```
6476
65- #### Testing future features
77+ ##### Testing future features
6678
6779Since ` podman-py ` follows stable releases of ` podman ` , tests are thought to be run against
6880libpod's versions that are commonly installed in the distributions. Tests can be versioned,
@@ -84,6 +96,41 @@ tox -e py -- --pnext -m pnext podman/tests/integration/test_container_create.py
8496The option ` --pnext ` ** enables** the tests with the ` pnext ` pytest marker, and ` -m pnext ` will run
8597the marked tests ** only** .
8698
99+ ##### Testing version-specific or distro-specific scenarios
100+
101+ Tests can be conditionally skipped based on ` podman ` 's version or on the host
102+ that's running the test suite.
103+
104+ ``` python
105+ from podman.tests.utils import OS_RELEASE , PODMAN_VERSION
106+
107+
108+ @pytest.mark.skipif (
109+ PODMAN_VERSION < (5 , 6 , 0 ),
110+ reason = " Feature introduced in Podman 5.6.0 https://github.com/..." ,
111+ )
112+ @pytest.mark.skipif (
113+ OS_RELEASE [" ID" ] == " fedora" and int (OS_RELEASE [" VERSION_ID" ]) < 42 ,
114+ reason = " Feature patched in F42 or later https://github.com/..." ,
115+ )
116+ ```
117+
118+ #### Common test issues
119+
120+ Tests work by establishing a ssh connection with localhost. If you see
121+ this line repeating after launching tox you might need to fix your ssh to be
122+ able to connect locally.
123+
124+ ``` log
125+ ...
126+ 2025-09-25 13:20:44 [ DEBUG] Waiting on /run/user/1000/podman/podman-forward-a65fd89525a248608d4c.sock (ssh.py:89)
127+ 2025-09-25 13:20:44 [ DEBUG] Waiting on /run/user/1000/podman/podman-forward-a65fd89525a248608d4c.sock (ssh.py:89)
128+ ...
129+ ```
130+
131+ Most of the times, if you can run ` ssh localhost exit ` successfully your tests
132+ will run.
133+
87134## Submitting changes
88135
89136- Create a github pull request (PR)
0 commit comments