mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
pytest: Migrate unittest/nose to Pytest fixtures
Even though Pytest supports xunit style setups, unittest and nose tests, this support is limited and may be dropped in the future releases. Worst of all is that the mixing of various test frameworks results in weird conflicts and of course, is not widely tested. This is a part of work to remove the mixing of test idioms in the IPA's test suite: 1) replace unittest.TestCase subclasses 2) replace unittest test controls (SkipTest, fail, etc.) 3) replace unittest assertions Related: https://pagure.io/freeipa/issue/7989 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
committed by
Alexander Bokovoy
parent
292d686c0b
commit
fec66942d4
@@ -29,7 +29,6 @@ from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
import six
|
||||
@@ -92,7 +91,7 @@ class test_ldap:
|
||||
with open(pwfile, "r") as fp:
|
||||
dm_password = fp.read().rstrip()
|
||||
else:
|
||||
raise unittest.SkipTest(
|
||||
pytest.skip(
|
||||
"No directory manager password in %s" % pwfile
|
||||
)
|
||||
self.conn = ldap2(api)
|
||||
@@ -118,7 +117,7 @@ class test_ldap:
|
||||
with open(pwfile, "r") as fp:
|
||||
dm_password = fp.read().rstrip()
|
||||
else:
|
||||
raise unittest.SkipTest(
|
||||
pytest.skip(
|
||||
"No directory manager password in %s" % pwfile
|
||||
)
|
||||
myapi.Backend.ldap2.connect(bind_dn=DN(('cn', 'Directory Manager')), bind_pw=dm_password)
|
||||
@@ -136,7 +135,7 @@ class test_ldap:
|
||||
try:
|
||||
self.conn.connect(autobind=True)
|
||||
except errors.ACIError:
|
||||
raise unittest.SkipTest("Only executed as root")
|
||||
pytest.skip("Only executed as root")
|
||||
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
|
||||
cert = entry_attrs.get('usercertificate')[0]
|
||||
assert cert.serial_number is not None
|
||||
|
||||
Reference in New Issue
Block a user