Python 3-compatibility fix to unit test

This should not be returning a string type for stderr, since
Popen.communicate() returns a bytestring. In Python 2, the str and bytes
types are the same, but the same is not true in Python 3.

Additionally, the mocking here seems not to consider the fact that Popen
is called when runas is used to get the runas user's environment. Since
this test doesn't care about the output, we can just make the mocked
Popen.communicate() return an empty bytestring.
This commit is contained in:
Erik Johnson 2018-03-20 22:09:18 -05:00
parent 27f651906d
commit e8582e80f2
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F

View file

@ -274,7 +274,7 @@ class CMDMODTestCase(TestCase, LoaderModuleMockMixin):
environment = os.environ.copy()
popen_mock.return_value = Mock(
communicate=lambda *args, **kwags: ['{}', None],
communicate=lambda *args, **kwags: [b'', None],
pid=lambda: 1,
retcode=0
)