test_ipalib.test_frontend: Port unbound method tests to Python 3

Python 3 uses plain function objects instead of unbound methods.
So, what was Class.method.__func__ is now just Class.method.

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin authored and Tomas Babej committed 2015-10-13 14:16:32 +02:00
1 parent 88ac1c1616
commit be876987f5
1 file changed
+16 -4
+16 -4
View File
@@ -648,7 +648,10 @@ class test_Command(ClassChecker):
(api, home) = create_test_api(in_server=True)
api.finalize()
o = my_cmd(api)
assert o.run.__func__ is self.cls.run.__func__
if six.PY2:
assert o.run.__func__ is self.cls.run.__func__
else:
assert o.run.__func__ is self.cls.run
out = o.run(*args, **kw)
assert ('execute', args, kw) == out
@@ -656,7 +659,10 @@ class test_Command(ClassChecker):
(api, home) = create_test_api(in_server=False)
api.finalize()
o = my_cmd(api)
assert o.run.__func__ is self.cls.run.__func__
if six.PY2:
assert o.run.__func__ is self.cls.run.__func__
else:
assert o.run.__func__ is self.cls.run
assert ('forward', args, kw) == o.run(*args, **kw)
def test_messages(self):
@@ -688,14 +694,20 @@ class test_Command(ClassChecker):
(api, home) = create_test_api(in_server=True)
api.finalize()
o = my_cmd(api)
assert o.run.__func__ is self.cls.run.__func__
if six.PY2:
assert o.run.__func__ is self.cls.run.__func__
else:
assert o.run.__func__ is self.cls.run
assert {'name': 'execute', 'messages': expected} == o.run(*args, **kw)
# Test in non-server context
(api, home) = create_test_api(in_server=False)
api.finalize()
o = my_cmd(api)
assert o.run.__func__ is self.cls.run.__func__
if six.PY2:
assert o.run.__func__ is self.cls.run.__func__
else:
assert o.run.__func__ is self.cls.run
assert {'name': 'forward', 'messages': expected} == o.run(*args, **kw)
def test_validate_output_basic(self):