Pytest generates warnings when using testinfra wrapper
See original GitHub issueRunning a simple test with the testinfra
wrapper generates a pytest warning in the console output. The tests pass/fail correctly and the command exits with a zero status code, but the warning is a little concerning. The warning is:
WP1 None Modules are already imported so can not be re-written: testinfra
Testinfra 1.42 Pytest 3.03 Python 2.7.12 macOS 10.12
$ cat mytest.py
def test_passwd_file(File):
passwd = File("/etc/passwd")
assert passwd.contains("root")
assert passwd.user == "root"
assert passwd.group == "wheel"
assert passwd.mode == 0o644
(venv)
$ testinfra -v mytest.py
==================================================================== test session starts =====================================================================
platform darwin -- Python 2.7.12, pytest-3.0.3, py-1.4.31, pluggy-0.4.0 -- /Users/me/testing/venv/bin/python2.7
cachedir: .cache
rootdir: /Users/me/testing, inifile:
plugins: testinfra-1.4.2
collected 1 items
mytest.py::test_passwd_file[local] PASSED
=================================================================== pytest-warning summary ===================================================================
WP1 None Modules are already imported so can not be re-written: testinfra
======================================================== 1 passed, 1 pytest-warnings in 0.04 seconds =========================================================```
Issue Analytics
- State:
- Created 7 years ago
- Reactions:20
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Pytest generates warnings when using testinfra wrapper #135
Running a simple test with the testinfra wrapper generates a pytest warning in the console output. The tests pass/fail correctly and the ...
Read more >How to capture warnings — pytest documentation
Recording warnings provides an opportunity to produce custom test failure messages for when no warnings are issued or other conditions are met. def...
Read more >pytest Documentation - Read the Docs
2.2.3 Assertions about expected warnings. You can check that code raises a particular warning using pytest.warns. 2.2.4 Making use of ...
Read more >Pytest-testinfra: Testinfra Test Your infrastructures - Morioh
With Testinfra you can write unit tests in Python to test actual state of your servers configured by management tools like Salt, Ansible,...
Read more >Examples — testinfra 7.0.2.dev1+gfc4bfd1.d20221210 ...
This recipe shows how to build and run Docker containers with Testinfra by overloading the host fixture. import pytest import subprocess import testinfra...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1
I get this same issue, even when not running it with Molecule.