Add workaround for pytest 3.3.0 bug

pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test
parameters. If parameters happen to contain NULL bytes, the putenv()
call fails with "ValueError: embedded null byte". The workaround uses
repr() of test parameters as parameter id.

See https://github.com/pytest-dev/pytest/issues/2957
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Christian Heimes
2017-11-28 13:16:36 +01:00
parent cd80036b6b
commit 4069c129ea

View File

@@ -74,8 +74,11 @@ openssh = 'ssh-rsa %s' % b64
(u'vanitas %s' % b64, ValueError), (u'vanitas %s' % b64, ValueError),
(u'@opt %s' % openssh, ValueError), (u'@opt %s' % openssh, ValueError),
(u'opt=val %s' % openssh, ValueError), (u'opt=val %s' % openssh, ValueError),
(u'opt, %s' % openssh, ValueError), (u'opt, %s' % openssh, ValueError)],
]) # ids=repr is workaround for pytest issue with NULL bytes,
# see https://github.com/pytest-dev/pytest/issues/2644
ids=repr
)
def test_public_key_parsing(pk, out): def test_public_key_parsing(pk, out):
if isinstance(out, type) and issubclass(out, Exception): if isinstance(out, type) and issubclass(out, Exception):
pytest.raises(out, ssh.SSHPublicKey, pk) pytest.raises(out, ssh.SSHPublicKey, pk)