Comments (5)
Well, I wanted to be able to skip a test based on a remote command. Here the command was 'hostname -s', but it could have been anything else. Is there a way to do that?
from pytest-testinfra.
Doesn't @pytest.mark.testinfra_hosts
already do something like that? See https://github.com/philpep/testinfra/blob/master/testinfra/test/test_backends.py
from pytest-testinfra.
@pytest.mark.testinfra_hosts does not work with Salt, we had to use the suggested workaround.
My team would be happy to extend @pytest.mark.testinfra_hosts
to support Salt.
Could you point us in the right direction? Thanks a lot.
from pytest-testinfra.
Do you have an idea @philpep? :)
from pytest-testinfra.
FWIW, a (more ansible specific) workaround.
My use case is ansible group intersection.
I'm pretty new to python and to pytest, but this seems to be elegant.
The approach is to define a conftest.py with a fixture:
@pytest.fixture(scope='class')
def groups(host):
return host.ansible.get_variables()['group_names']
Then add groups
to the test function parameters, and add a line like
if 'GROUP_NAME' in groups:
This avoids pytest.skip()
which, for my usage is a plus.
from pytest-testinfra.
Related Issues (20)
- pytest-testinfra breaks native pytest features HOT 1
- Timeout argument for run() HOT 7
- Executing tests from Ansible Tower/Ansible AWX
- The package comparison option in the package module is not working as expected. HOT 1
- Testinfra fails if the "~/.ansible/cp" path doesn't exist HOT 2
- Environment class not clickable in module documenation
- changelog missing for v10.0.0
- Winrm Issue
- service is_running does not work with exit code 4 HOT 1
- Support for user and global service for systemd ?
- Don't correctly parse contain @ ssh password HOT 2
- Broken compatibility with pytest<7 (pytest.Parser type annotation) HOT 6
- `SystemdService.exists` fails with an error due to a malformed command HOT 2
- `host.package().is_installed` is returning True incorrectly when the RPM database is corrupted.
- pre-commit fails on Python 3.12
- File.user on symlink has changed comportement
- service.exists with systemd fails
- Got empty parameter set ['_testinfra_host'] after update HOT 1
- zlib1g not detected by package module HOT 1
- Consider using the Docker/Podman API instead of subprocess?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-testinfra.