question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pytest generates warnings when using testinfra wrapper

See original GitHub issue

Running 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:closed
  • Created 7 years ago
  • Reactions:20
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
adeleglisecommented, Nov 29, 2016

+1

1reaction
wachpwnskicommented, Aug 7, 2017

I get this same issue, even when not running it with Molecule.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found