You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.net.biosdevname: Fix Popen() using universal_newlines=True, add test
This PR fixes the Popen() in xcp.net.biosdevname like xenserver#38 fixed
the Popen of xcp.pci.PCIDevices() using universial_newlines=True,
to make the Popen return strings as expected by the code, not bytes.
Redirects the call to /sbin/biosdevname to tests/data/biosdevname
to provide the test data to tests/test_biosdevname.py:test_nomock()
Adds a new test case because the old test case is using the same
mock which already failed to find the issue in xenserver#38.
Unlike xenserver#38, the new test can't do this by setting PATH="tests/data"
because /sbin/biosdevname is an absolute path.
To ensure a correct test, the new test avoids mocking Popen() by
installing a wrapper for subprocess.Popen() in tests/conftest.py.
This needs to be done a global wrapper in pytest in tests/conftest.py
because when another test module in the same pytest run imports the
testee module first and does not provide the wrapped subprocess.Popen,
when importing it, the wrapper for Popen is not installed.
The benefit is that this wrapper can be used by all tests for modules
which use subprocess.Popen(), and trace all of them from a central
place. This can e.g. be used to check the subprocess call done during
a testsuite run.
0 commit comments