diff options
Diffstat (limited to 'ipatests')
-rwxr-xr-x | ipatests/i18n.py | 50 | ||||
-rwxr-xr-x | ipatests/ipa-test-config | 4 | ||||
-rwxr-xr-x | ipatests/ipa-test-task | 3 | ||||
-rw-r--r-- | ipatests/pytest_plugins/integration.py | 4 | ||||
-rw-r--r-- | ipatests/test_integration/test_backup_and_restore.py | 4 | ||||
-rw-r--r-- | ipatests/test_integration/test_simple_replication.py | 4 | ||||
-rw-r--r-- | ipatests/test_ipalib/test_aci.py | 13 | ||||
-rw-r--r-- | ipatests/test_ipalib/test_backend.py | 11 | ||||
-rw-r--r-- | ipatests/test_ipalib/test_rpc.py | 11 | ||||
-rw-r--r-- | ipatests/test_ipalib/test_text.py | 3 | ||||
-rw-r--r-- | ipatests/test_webui/ui_driver.py | 3 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/ldaptracker.py | 7 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_host_plugin.py | 3 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_permission_plugin.py | 3 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/xmlrpc_test.py | 5 |
15 files changed, 74 insertions, 54 deletions
diff --git a/ipatests/i18n.py b/ipatests/i18n.py index 369871658..813b78982 100755 --- a/ipatests/i18n.py +++ b/ipatests/i18n.py @@ -19,6 +19,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function + # WARNING: Do not import ipa modules, this is also used as a # stand-alone script (invoked from install/po Makefile). import optparse @@ -387,12 +389,12 @@ def validate_file(file_path, validation_mode, reference_pot=None): if n_warnings: warning_lines.insert(0, section_seperator) warning_lines.insert(1, "%d validation warnings in %s" % (n_warnings, file_path)) - print '\n'.join(warning_lines) + print('\n'.join(warning_lines)) if n_errors: error_lines.insert(0, section_seperator) error_lines.insert(1, "%d validation errors in %s" % (n_errors, file_path)) - print '\n'.join(error_lines) + print('\n'.join(error_lines)) Result = namedtuple('ValidateFileResult', ['n_entries', 'n_msgids', 'n_msgstrs', 'n_warnings', 'n_errors']) @@ -524,12 +526,12 @@ def validate_file(file_path, validation_mode, reference_pot=None): def create_po(pot_file, po_file, mo_file): if not os.path.isfile(pot_file): - print >>sys.stderr, 'file does not exist "%s"' % (pot_file) + print('file does not exist "%s"' % (pot_file), file=sys.stderr) return 1 try: po = polib.pofile(pot_file) except Exception as e: - print >>sys.stderr, 'Unable to parse file "%s": %s' % (pot_file, e) + print('Unable to parse file "%s": %s' % (pot_file, e), file=sys.stderr) return 1 # Update the metadata in the po file header @@ -559,10 +561,10 @@ def create_po(pot_file, po_file, mo_file): # Write out the po and mo files po.save(po_file) - print "Wrote: %s" % (po_file) + print("Wrote: %s" % (po_file)) po.save_as_mofile(mo_file) - print "Wrote: %s" % (mo_file) + print("Wrote: %s" % (mo_file)) return 0 @@ -587,7 +589,7 @@ def validate_unicode_edit(msgid, msgstr): if verbose: msg = 'Success: message string "%s" maps to translated string "%s"' % (msgid, msgstr) - print msg.encode('utf-8') + print(msg.encode('utf-8')) def test_translations(po_file, lang, domain, locale_dir): @@ -615,12 +617,12 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural): try: # Iterate over the msgid's if not os.path.isfile(po_file): - print >>sys.stderr, 'file does not exist "%s"' % (po_file) + print('file does not exist "%s"' % (po_file), file=sys.stderr) return 1 try: po = polib.pofile(po_file) except Exception as e: - print >>sys.stderr, 'Unable to parse file "%s": %s' % (po_file, e) + print('Unable to parse file "%s": %s' % (po_file, e), file=sys.stderr) return 1 n_entries = 0 @@ -642,7 +644,7 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural): n_fail += 1 if print_traceback: traceback.print_exc() - print >> sys.stderr, "ERROR: %s" % e + print("ERROR: %s" % e, file=sys.stderr) try: n_translations += 1 @@ -652,7 +654,7 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural): n_fail += 1 if print_traceback: traceback.print_exc() - print >> sys.stderr, "ERROR: %s" % e + print("ERROR: %s" % e, file=sys.stderr) else: @@ -667,25 +669,25 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural): n_fail += 1 if print_traceback: traceback.print_exc() - print >> sys.stderr, "ERROR: %s" % e + print("ERROR: %s" % e, file=sys.stderr) n_entries += 1 except Exception as e: if print_traceback: traceback.print_exc() - print >> sys.stderr, "ERROR: %s" % e + print("ERROR: %s" % e, file=sys.stderr) return 1 if not n_entries: - print >> sys.stderr, "ERROR: no translations found in %s" % (po_file) + print("ERROR: no translations found in %s" % (po_file), file=sys.stderr) return 1 if n_fail: - print >> sys.stderr, "ERROR: %d failures out of %d translations" % (n_fail, n_entries) + print("ERROR: %d failures out of %d translations" % (n_fail, n_entries), file=sys.stderr) return 1 - print "%d translations in %d messages successfully tested" % (n_translations, n_entries) + print("%d translations in %d messages successfully tested" % (n_translations, n_entries)) return 0 #---------------------------------------------------------------------- @@ -751,7 +753,7 @@ def main(): show_strings = options.show_strings if not options.mode: - print >> sys.stderr, 'ERROR: no mode specified' + print('ERROR: no mode specified', file=sys.stderr) return 1 if options.mode == 'validate_pot' or options.mode == 'validate_po': @@ -764,12 +766,12 @@ def main(): elif options.mode == 'validate_po': files = args if not files: - print >> sys.stderr, 'ERROR: no po files specified' + print('ERROR: no po files specified', file=sys.stderr) return 1 validation_mode = 'po' reference_pot = polib.pofile(options.pot_file) else: - print >> sys.stderr, 'ERROR: unknown validation mode "%s"' % (options.mode) + print('ERROR: unknown validation mode "%s"' % (options.mode), file=sys.stderr) return 1 total_entries = 0 @@ -785,11 +787,11 @@ def main(): total_msgstrs += result.n_msgstrs total_warnings += result.n_warnings total_errors += result.n_errors - print "%s: %d entries, %d msgid, %d msgstr, %d warnings %d errors" % \ - (f, result.n_entries, result.n_msgids, result.n_msgstrs, result.n_warnings, result.n_errors) + print("%s: %d entries, %d msgid, %d msgstr, %d warnings %d errors" % \ + (f, result.n_entries, result.n_msgids, result.n_msgstrs, result.n_warnings, result.n_errors)) if total_errors: - print section_seperator - print "%d errors in %d files" % (total_errors, len(files)) + print(section_seperator) + print("%d errors in %d files" % (total_errors, len(files))) return 1 else: return 0 @@ -831,7 +833,7 @@ def main(): return test_translations(po_file, lang, domain, locale_dir) else: - print >> sys.stderr, 'ERROR: unknown mode "%s"' % (options.mode) + print('ERROR: unknown mode "%s"' % (options.mode), file=sys.stderr) return 1 if __name__ == "__main__": diff --git a/ipatests/ipa-test-config b/ipatests/ipa-test-config index 6a3101f63..cc3714fa4 100755 --- a/ipatests/ipa-test-config +++ b/ipatests/ipa-test-config @@ -19,6 +19,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from __future__ import print_function + import sys import os import argparse @@ -154,4 +156,4 @@ def get_object(conf, args): if __name__ == '__main__': - print main(sys.argv[1:]), + print(main(sys.argv[1:]), end=' ') diff --git a/ipatests/ipa-test-task b/ipatests/ipa-test-task index 192814c48..4939d5068 100755 --- a/ipatests/ipa-test-task +++ b/ipatests/ipa-test-task @@ -19,6 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from __future__ import print_function import sys import os @@ -388,7 +389,7 @@ class TaskRunner(object): def list_topos(self, args): for name, topo in tasks.topologies.items(): - print '%s: %s' % (name, topo.__doc__) + print('%s: %s' % (name, topo.__doc__)) def install_topo(self, args): master = self.get_host(args.master, default=args.domain.master) diff --git a/ipatests/pytest_plugins/integration.py b/ipatests/pytest_plugins/integration.py index 1dddf5b8c..5ece99680 100644 --- a/ipatests/pytest_plugins/integration.py +++ b/ipatests/pytest_plugins/integration.py @@ -19,6 +19,8 @@ """Pytest plugin for IPA Integration tests""" +from __future__ import print_function + import os import tempfile import shutil @@ -192,7 +194,7 @@ def mh(request, class_integration_logs): (host.external_hostname, filename)) class_integration_logs.setdefault(host, []).append(filename) - print mh.config + print(mh.config) for host in mh.config.get_all_hosts(): host.add_log_collector(collect_log) cls.log.info('Preparing host %s', host.hostname) diff --git a/ipatests/test_integration/test_backup_and_restore.py b/ipatests/test_integration/test_backup_and_restore.py index c9b4271d4..0ce1aaf29 100644 --- a/ipatests/test_integration/test_backup_and_restore.py +++ b/ipatests/test_integration/test_backup_and_restore.py @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from __future__ import print_function + import os import re import contextlib @@ -50,7 +52,7 @@ def check_admin_in_ldap(host): basedn = host.domain.basedn user_dn = DN(('uid', 'admin'), ('cn', 'users'), ('cn', 'accounts'), basedn) entry = ldap.get_entry(user_dn) - print entry + print(entry) assert entry.dn == user_dn assert entry['uid'] == ['admin'] diff --git a/ipatests/test_integration/test_simple_replication.py b/ipatests/test_integration/test_simple_replication.py index f1da22f50..fe1c74e7c 100644 --- a/ipatests/test_integration/test_simple_replication.py +++ b/ipatests/test_integration/test_simple_replication.py @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from __future__ import print_function + from ipapython.dn import DN from ipatests.test_integration.base import IntegrationTest from ipatests.test_integration import tasks @@ -47,7 +49,7 @@ class TestSimpleReplication(IntegrationTest): user_dn = DN(('uid', login), ('cn', 'users'), ('cn', 'accounts'), basedn) entry = ldap.get_entry(user_dn) - print entry + print(entry) assert entry.dn == user_dn assert entry['uid'] == [login] diff --git a/ipatests/test_ipalib/test_aci.py b/ipatests/test_ipalib/test_aci.py index 40ba5e88c..794d4e82b 100644 --- a/ipatests/test_ipalib/test_aci.py +++ b/ipatests/test_ipalib/test_aci.py @@ -21,13 +21,14 @@ """ Test the `ipalib.aci` module. """ +from __future__ import print_function from ipalib.aci import ACI def check_aci_parsing(source, expected): a = ACI(source) - print 'ACI was: ', a - print 'Expected:', expected + print('ACI was: ', a) + print('Expected:', expected) assert str(ACI(source)) == expected def test_aci_parsing_1(): @@ -76,7 +77,7 @@ def make_test_aci(): def test_aci_equality(): a = make_test_aci() - print a + print(a) b = ACI() b.name ="foo" @@ -85,7 +86,7 @@ def test_aci_equality(): b.set_bindrule_operator("=") b.set_bindrule_expression("\"ldap:///cn=foo,cn=groups,cn=accounts,dc=example,dc=com\"") b.permissions = ['add','read','write'] - print b + print(b) assert a.isequal(b) assert a == b @@ -94,8 +95,8 @@ def test_aci_equality(): def check_aci_inequality(b): a = make_test_aci() - print a - print b + print(a) + print(b) assert not a.isequal(b) assert not a == b diff --git a/ipatests/test_ipalib/test_backend.py b/ipatests/test_ipalib/test_backend.py index 756d434e3..f7887bf64 100644 --- a/ipatests/test_ipalib/test_backend.py +++ b/ipatests/test_ipalib/test_backend.py @@ -20,6 +20,7 @@ """ Test the `ipalib.backend` module. """ +from __future__ import print_function # FIXME: Pylint errors # pylint: disable=no-member @@ -223,11 +224,11 @@ class test_Executioner(ClassChecker): # Test that CommandError is raised: conn = Connection('The connection.', Disconnect('someconn')) context.someconn = conn - print str(list(context.__dict__)) + print(str(list(context.__dict__))) e = raises(errors.CommandError, o.execute, 'nope') assert e.name == 'nope' assert conn.disconnect.called is True # Make sure destroy_context() was called - print str(list(context.__dict__)) + print(str(list(context.__dict__))) assert list(context.__dict__) == [] # Test with echo command: @@ -239,10 +240,10 @@ class test_Executioner(ClassChecker): conn = Connection('The connection.', Disconnect('someconn')) context.someconn = conn - print o.execute('echo', arg1, arg2, **options) - print dict( + print(o.execute('echo', arg1, arg2, **options)) + print(dict( result=(arg1, arg2, options) - ) + )) assert o.execute('echo', arg1, arg2, **options) == dict( result=(arg1, arg2, options) ) diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py index dd24d055c..5c130bdc6 100644 --- a/ipatests/test_ipalib/test_rpc.py +++ b/ipatests/test_ipalib/test_rpc.py @@ -20,6 +20,7 @@ """ Test the `ipalib.rpc` module. """ +from __future__ import print_function from xmlrpclib import Binary, Fault, dumps, loads @@ -275,7 +276,7 @@ class test_xml_introspection(object): try: result = api.Backend.xmlclient.conn.system.listMethods('foo') except Fault as f: - print f + print(f) assert f.faultCode == 3003 assert f.faultString == ( "command 'system.listMethods' takes no arguments") @@ -295,7 +296,7 @@ class test_xml_introspection(object): try: result = api.Backend.xmlclient.conn.system.methodSignature() except Fault as f: - print f + print(f) assert f.faultCode == 3007 assert f.faultString == "'method name' is required" else: @@ -305,7 +306,7 @@ class test_xml_introspection(object): try: result = api.Backend.xmlclient.conn.system.methodSignature('a', 'b') except Fault as f: - print f + print(f) assert f.faultCode == 3004 assert f.faultString == ( "command 'system.methodSignature' takes at most 1 argument") @@ -316,7 +317,7 @@ class test_xml_introspection(object): try: result = api.Backend.xmlclient.conn.system.methodHelp() except Fault as f: - print f + print(f) assert f.faultCode == 3007 assert f.faultString == "'method name' is required" else: @@ -326,7 +327,7 @@ class test_xml_introspection(object): try: result = api.Backend.xmlclient.conn.system.methodHelp('a', 'b') except Fault as f: - print f + print(f) assert f.faultCode == 3004 assert f.faultString == ( "command 'system.methodHelp' takes at most 1 argument") diff --git a/ipatests/test_ipalib/test_text.py b/ipatests/test_ipalib/test_text.py index c1140d217..c6ab38887 100644 --- a/ipatests/test_ipalib/test_text.py +++ b/ipatests/test_ipalib/test_text.py @@ -20,6 +20,7 @@ """ Test the `ipalib.text` module. """ +from __future__ import print_function import os import shutil @@ -93,7 +94,7 @@ class test_TestLang(object): shutil.rmtree(self.tmp_dir) def test_test_lang(self): - print "test_test_lang" + print("test_test_lang") # The test installs the test message catalog under the xh_ZA # (e.g. Zambia Xhosa) language by default. It would be nice to # use a dummy language not associated with any real language, diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index d097a5490..6f2013c4a 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -22,6 +22,7 @@ Base class for UI integration tests. Contains browser driver and common tasks. """ +from __future__ import print_function import nose from datetime import datetime @@ -934,7 +935,7 @@ class UI_driver(object): checkbox = self.find(input_s, By.CSS_SELECTOR, parent, strict=True) checkbox_id = checkbox.get_attribute('id') label_s = s + " tbody td label[for='%s']" % checkbox_id - print label_s + print(label_s) label = self.find(label_s, By.CSS_SELECTOR, parent, strict=True) try: ActionChains(self.driver).move_to_element(label).click().perform() diff --git a/ipatests/test_xmlrpc/ldaptracker.py b/ipatests/test_xmlrpc/ldaptracker.py index bf753a5c5..acd382dd3 100644 --- a/ipatests/test_xmlrpc/ldaptracker.py +++ b/ipatests/test_xmlrpc/ldaptracker.py @@ -5,6 +5,7 @@ """ Implements a base class to track changes to an LDAP object. """ +from __future__ import print_function import functools @@ -126,11 +127,11 @@ class Tracker(object): try: result = cmd(*args, **options) except Exception as e: - print 'Ran command: %s(%s): %s: %s' % (cmd, args_repr, - type(e).__name__, e) + print('Ran command: %s(%s): %s: %s' % (cmd, args_repr, + type(e).__name__, e)) raise else: - print 'Ran command: %s(%s): OK' % (cmd, args_repr) + print('Ran command: %s(%s): OK' % (cmd, args_repr)) return result def make_command(self, name, *args, **options): diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py index 4c574b957..bba86492e 100644 --- a/ipatests/test_xmlrpc/test_host_plugin.py +++ b/ipatests/test_xmlrpc/test_host_plugin.py @@ -22,6 +22,7 @@ """ Test the `ipalib.plugins.host` module. """ +from __future__ import print_function import os import tempfile @@ -689,7 +690,7 @@ class TestHostFalsePwdChange(XMLRPC_test): except ipautil.CalledProcessError as e: # join operation may fail on 'adding key into keytab', but # the keytab is not necessary for further tests - print e + print(e) host.attrs['has_keytab'] = True host.attrs['has_password'] = False diff --git a/ipatests/test_xmlrpc/test_permission_plugin.py b/ipatests/test_xmlrpc/test_permission_plugin.py index 971d0e6cb..e791b5981 100644 --- a/ipatests/test_xmlrpc/test_permission_plugin.py +++ b/ipatests/test_xmlrpc/test_permission_plugin.py @@ -21,6 +21,7 @@ """ Test the `ipalib/plugins/permission.py` module. """ +from __future__ import print_function import os @@ -2847,7 +2848,7 @@ def check_legacy_results(results): """Check that the expected number of legacy permissions are in $SUFFIX""" legacy_permissions = [p for p in results if not p.get('ipapermissiontype')] - print legacy_permissions + print(legacy_permissions) assert len(legacy_permissions) == 8, len(legacy_permissions) return True diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py index 65686211d..56ddad9b8 100644 --- a/ipatests/test_xmlrpc/xmlrpc_test.py +++ b/ipatests/test_xmlrpc/xmlrpc_test.py @@ -20,6 +20,7 @@ """ Base class for all XML-RPC tests """ +from __future__ import print_function import datetime @@ -274,7 +275,7 @@ class Declarative(XMLRPC_test): @classmethod def cleanup(cls, command): (cmd, args, options) = command - print 'Cleanup:', cmd, args, options + print('Cleanup:', cmd, args, options) if cmd not in api.Command: raise nose.SkipTest( 'cleanup command %r not in api.Command' % cmd @@ -282,7 +283,7 @@ class Declarative(XMLRPC_test): try: api.Command[cmd](*args, **options) except (errors.NotFound, errors.EmptyModlist) as e: - print e + print(e) pass def test_command(self, index, declarative_test_definition): |