mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
test_ipapython: Use functions instead of classes in test generators
pytest's support for Nose-style test generators is not bulletproof; use a real function to please it. https://fedorahosted.org/freeipa/ticket/4610 Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
parent
82e41dc7a4
commit
387b8b46b8
@ -24,16 +24,17 @@ import nose
|
||||
|
||||
from ipapython import ipautil
|
||||
|
||||
class CheckIPAddress:
|
||||
def __init__(self, addr):
|
||||
self.description = "Test IP address parsing and verification (%s)" % addr
|
||||
|
||||
def __call__(self, addr, words=None, prefixlen=None):
|
||||
def make_ipaddress_checker(addr, words=None, prefixlen=None):
|
||||
def check_ipaddress():
|
||||
try:
|
||||
ip = ipautil.CheckedIPAddress(addr, match_local=False)
|
||||
assert ip.words == words and ip.prefixlen == prefixlen
|
||||
except:
|
||||
assert words is None and prefixlen is None
|
||||
check_ipaddress.description = "Test IP address parsing and verification (%s)" % addr
|
||||
return check_ipaddress
|
||||
|
||||
|
||||
def test_ip_address():
|
||||
addrs = [
|
||||
@ -66,7 +67,7 @@ def test_ip_address():
|
||||
]
|
||||
|
||||
for addr in addrs:
|
||||
yield (CheckIPAddress(addr[0]),) + addr
|
||||
yield make_ipaddress_checker(*addr)
|
||||
|
||||
|
||||
class TestCIDict(object):
|
||||
|
@ -25,16 +25,15 @@ import nose
|
||||
|
||||
from ipapython import ssh
|
||||
|
||||
class CheckPublicKey:
|
||||
def __init__(self, pk):
|
||||
self.description = "Test SSH public key parsing (%s)" % repr(pk)
|
||||
|
||||
def __call__(self, pk, out):
|
||||
def make_public_key_checker(pk, out):
|
||||
def check_public_key():
|
||||
try:
|
||||
parsed = ssh.SSHPublicKey(pk)
|
||||
assert parsed.openssh() == out
|
||||
except Exception, e:
|
||||
assert type(e) is out
|
||||
check_public_key.description = "Test SSH public key parsing (%s)" % repr(pk)
|
||||
return check_public_key
|
||||
|
||||
def test_public_key_parsing():
|
||||
b64 = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDGAX3xAeLeaJggwTqMjxNwa6XHBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGIwA8GI48Z0qBS2NBMJ2u9WQ2hjLN6GdMlo77O0uJY3251p12pCVIS/bHRSq8kHO2No8g7KA9fGGcagPfQH+ee3t7HUkpbQkFTmbPPN++r3V8oVUk5LxbryB3UIIVzNmcSIn3JrXynlvui4MixvrtX6zx+O/bBo68o8/eZD26QrahVbA09fivrn/4h3TM019Eu/c2jOdckfU3cHUV/3Tno5d6JicibyaoDDK7S/yjdn5jhaz8MSEayQvFkZkiF0L'
|
||||
@ -73,4 +72,4 @@ def test_public_key_parsing():
|
||||
]
|
||||
|
||||
for pk in pks:
|
||||
yield (CheckPublicKey(pk[0]),) + pk
|
||||
yield make_public_key_checker(*pk)
|
||||
|
Loading…
Reference in New Issue
Block a user