diff options
42 files changed, 93 insertions, 111 deletions
diff --git a/ipatests/i18n.py b/ipatests/i18n.py index 7864c8ab2..64e078fa8 100755 --- a/ipatests/i18n.py +++ b/ipatests/i18n.py @@ -345,7 +345,7 @@ def validate_positional_substitutions(s, prog_langs, s_name='string'): errors = [] if n_fmts > 1: - for i, fmt_parts in enumerate(fmts): + for fmt_parts in fmts: fmt = fmt_parts['fmt'] fmt_arg = fmt_parts['fmt_arg'] width = fmt_parts['width'] @@ -543,7 +543,7 @@ def create_po(pot_file, po_file, mo_file): # # It is demanding the rhs of plural= only contains the identifer 'n' - for k,v in po.metadata.items(): + for k in po.metadata: if k.lower() == 'plural-forms': po.metadata[k] = 'nplurals=2; plural=(n != 1)' break diff --git a/ipatests/pytest_plugins/declarative.py b/ipatests/pytest_plugins/declarative.py index 64e9b0bcd..529856b60 100644 --- a/ipatests/pytest_plugins/declarative.py +++ b/ipatests/pytest_plugins/declarative.py @@ -23,7 +23,6 @@ def pytest_generate_tests(metafunc): """Generates Declarative tests""" if 'declarative_test_definition' in metafunc.fixturenames: - name = metafunc.cls.__name__ tests = [] descriptions = [] for i, test in enumerate(metafunc.cls.tests): diff --git a/ipatests/test_cmdline/test_help.py b/ipatests/test_cmdline/test_help.py index 0c0ae9a55..b28aa2303 100644 --- a/ipatests/test_cmdline/test_help.py +++ b/ipatests/test_cmdline/test_help.py @@ -141,6 +141,6 @@ def test_multiline_description(): assert '\n\n' in unicode(api.Command.trust_add.doc).strip() with CLITestContext(exception=SystemExit) as help_ctx: - return_value = api.Backend.cli.run(['trust-add', '-h']) + api.Backend.cli.run(['trust-add', '-h']) assert unicode(api.Command.trust_add.doc).strip() in help_ctx.stdout diff --git a/ipatests/test_cmdline/test_ipagetkeytab.py b/ipatests/test_cmdline/test_ipagetkeytab.py index 6a1314f6c..b3c8491a1 100644 --- a/ipatests/test_cmdline/test_ipagetkeytab.py +++ b/ipatests/test_cmdline/test_ipagetkeytab.py @@ -114,7 +114,7 @@ class test_ipagetkeytab(cmdline_test): self.keytabname) assert expected in result.error_output, ( 'Success message not in output:\n%s' % result.error_output) - except ipautil.CalledProcessError as e: + except ipautil.CalledProcessError: assert (False) def test_3_use(self): diff --git a/ipatests/test_integration/env_config.py b/ipatests/test_integration/env_config.py index 3596b6fd4..6e3770fbb 100644 --- a/ipatests/test_integration/env_config.py +++ b/ipatests/test_integration/env_config.py @@ -279,7 +279,7 @@ def domain_from_env(env, config, index, domain_type): env_suffix = '_env%s' % index master_env = '%s%s' % (master_role, env_suffix) - hostname, dot, domain_name = env[master_env].partition('.') + hostname, _dot, domain_name = env[master_env].partition('.') domain = Domain(config, domain_name, domain_type) for role in _roles_from_env(domain, env, env_suffix): diff --git a/ipatests/test_integration/test_testconfig.py b/ipatests/test_integration/test_testconfig.py index 3b08bf217..6146d0d84 100644 --- a/ipatests/test_integration/test_testconfig.py +++ b/ipatests/test_integration/test_testconfig.py @@ -420,7 +420,7 @@ class TestComplexConfig(CheckConfig): def check_config(self, conf): assert len(conf.domains) == 3 main_dom = conf.domains[0] - (client1, client2, extra, extram1, extram2, master, + (client1, client2, extra, extram1, extram2, _master, replica1, replica2) = sorted(main_dom.hosts, key=lambda h: h.role) assert main_dom.name == 'ipadomain.test' assert main_dom.type == 'IPA' diff --git a/ipatests/test_integration/test_topology.py b/ipatests/test_integration/test_topology.py index 4cdcd46a1..c095812c4 100644 --- a/ipatests/test_integration/test_topology.py +++ b/ipatests/test_integration/test_topology.py @@ -188,9 +188,8 @@ class TestTopologyOptions(IntegrationTest): returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas) assert returncode != 0, error1 assert error.count(text) == 1, error2 % error - newseg, err = tasks.create_segment(self.master, - self.master, - self.replicas[1]) + _newseg, err = tasks.create_segment( + self.master, self.master, self.replicas[1]) assert err == "", err returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas) assert returncode == 0, error diff --git a/ipatests/test_ipalib/test_backend.py b/ipatests/test_ipalib/test_backend.py index 6fb2d8558..9fd99d8a3 100644 --- a/ipatests/test_ipalib/test_backend.py +++ b/ipatests/test_ipalib/test_backend.py @@ -189,7 +189,7 @@ class test_Executioner(ClassChecker): """ Test the `ipalib.backend.Executioner.execute` method. """ - (api, home) = create_test_api(in_server=True) + api, _home = create_test_api(in_server=True) class echo(Command): takes_args = ('arg1', 'arg2+') diff --git a/ipatests/test_ipalib/test_base.py b/ipatests/test_ipalib/test_base.py index d69ee67f6..c4e4a4cd6 100644 --- a/ipatests/test_ipalib/test_base.py +++ b/ipatests/test_ipalib/test_base.py @@ -263,9 +263,9 @@ class test_NameSpace(ClassChecker): Test the `ipalib.base.NameSpace.__len__` method. """ for count in (5, 18, 127): - (o, members) = self.new(count) + o, _members = self.new(count) assert len(o) == count - (o, members) = self.new(count, sort=False) + o, _members = self.new(count, sort=False) assert len(o) == count def test_iter(self): @@ -353,7 +353,7 @@ class test_NameSpace(ClassChecker): """ for cnt in (0, 1, 2): for sort in (True, False): - (o, members) = self.new(cnt, sort=sort) + o, _members = self.new(cnt, sort=sort) if cnt == 1: assert repr(o) == \ 'NameSpace(<%d member>, sort=%r)' % (cnt, sort) diff --git a/ipatests/test_ipalib/test_config.py b/ipatests/test_ipalib/test_config.py index 22851559a..22373e150 100644 --- a/ipatests/test_ipalib/test_config.py +++ b/ipatests/test_ipalib/test_config.py @@ -577,7 +577,7 @@ class test_Env(ClassChecker): Test the `ipalib.config.Env._finalize` method. """ # Check that calls cascade up the chain: - (o, home) = self.new(in_tree=True) + o, _home = self.new(in_tree=True) assert o._isdone('_bootstrap') is False assert o._isdone('_finalize_core') is False assert o._isdone('_finalize') is False @@ -591,7 +591,7 @@ class test_Env(ClassChecker): assert str(e) == 'Env._finalize() already called' # Check that _finalize() calls __lock__() - (o, home) = self.new(in_tree=True) + o, _home = self.new(in_tree=True) assert o.__islocked__() is False o._finalize() assert o.__islocked__() is True @@ -599,7 +599,7 @@ class test_Env(ClassChecker): assert str(e) == 'Env.__lock__() already called' # Check that **lastchance works - (o, home) = self.finalize_core(None) + o, _home = self.finalize_core(None) key = 'just_one_more_key' value = u'with one more value' lastchance = {key: value} diff --git a/ipatests/test_ipalib/test_crud.py b/ipatests/test_ipalib/test_crud.py index 125b82465..705ff3c16 100644 --- a/ipatests/test_ipalib/test_crud.py +++ b/ipatests/test_ipalib/test_crud.py @@ -38,7 +38,7 @@ class CrudChecker(ClassChecker): """ Return a finalized `ipalib.plugable.API` instance. """ - (api, home) = get_api() + api, _home = get_api() class user(frontend.Object): takes_params = ( 'givenname', diff --git a/ipatests/test_ipalib/test_errors.py b/ipatests/test_ipalib/test_errors.py index 8bf2cba45..43cd92654 100644 --- a/ipatests/test_ipalib/test_errors.py +++ b/ipatests/test_ipalib/test_errors.py @@ -243,7 +243,6 @@ class test_PublicError(PublicExceptionTester): def test_init(self): message = u'The translated, interpolated message' format = 'key=%(key1)r and key2=%(key2)r' - uformat = u'Translated key=%(key1)r and key2=%(key2)r' val1 = u'Value 1' val2 = u'Value 2' kw = dict(key1=val1, key2=val2) @@ -303,7 +302,6 @@ class test_PublicError(PublicExceptionTester): class subclass(self.klass): format = '%(true)r %(text)r %(number)r' - uformat = u'Translated %(true)r %(text)r %(number)r' kw = dict(true=True, text=u'Hello!', number=18) # Test with format=str, message=None diff --git a/ipatests/test_ipalib/test_plugable.py b/ipatests/test_ipalib/test_plugable.py index 8617c7343..1ee110250 100644 --- a/ipatests/test_ipalib/test_plugable.py +++ b/ipatests/test_ipalib/test_plugable.py @@ -103,14 +103,12 @@ def test_Registry(): pass class Base2(object): pass - class Base3(object): - pass + + class plugin1(Base1): pass class plugin2(Base2): pass - class plugin3(Base3): - pass # Test creation of Registry: r = plugable.Registry() @@ -250,7 +248,7 @@ class test_API(ClassChecker): """ Test the `ipalib.plugable.API.bootstrap` method. """ - (o, home) = create_test_api() + o, _home = create_test_api() assert o.env._isdone('_bootstrap') is False assert o.env._isdone('_finalize_core') is False assert o.isdone('bootstrap') is False @@ -266,7 +264,7 @@ class test_API(ClassChecker): """ Test the `ipalib.plugable.API.load_plugins` method. """ - (o, home) = create_test_api() + o, _home = create_test_api() assert o.isdone('bootstrap') is False assert o.isdone('load_plugins') is False o.load_plugins() diff --git a/ipatests/test_ipalib/test_x509.py b/ipatests/test_ipalib/test_x509.py index 32d0e8561..f765bc964 100644 --- a/ipatests/test_ipalib/test_x509.py +++ b/ipatests/test_ipalib/test_x509.py @@ -55,20 +55,20 @@ class test_x509(object): """ # Load a good cert - cert = x509.load_certificate(goodcert) + x509.load_certificate(goodcert) # Load a good cert with headers newcert = '-----BEGIN CERTIFICATE-----' + goodcert + '-----END CERTIFICATE-----' - cert = x509.load_certificate(newcert) + x509.load_certificate(newcert) # Load a good cert with bad headers newcert = '-----BEGIN CERTIFICATE-----' + goodcert with pytest.raises((TypeError, ValueError)): - cert = x509.load_certificate(newcert) + x509.load_certificate(newcert) # Load a bad cert with pytest.raises(NSPRError): - cert = x509.load_certificate(badcert) + x509.load_certificate(badcert) def test_1_load_der_cert(self): """ @@ -78,7 +78,7 @@ class test_x509(object): der = base64.b64decode(goodcert) # Load a good cert - cert = x509.load_certificate(der, x509.DER) + x509.load_certificate(der, x509.DER) def test_2_get_subject(self): """ diff --git a/ipatests/test_ipapython/test_cookie.py b/ipatests/test_ipapython/test_cookie.py index 6af447984..57233b7b0 100644 --- a/ipatests/test_ipapython/test_cookie.py +++ b/ipatests/test_ipapython/test_cookie.py @@ -279,7 +279,7 @@ class TestInvalidAttributes(unittest.TestCase): # Invalid Max-Age s = 'color=blue; Max-Age=over-the-hill' with self.assertRaises(ValueError): - cookies = Cookie.parse(s) + Cookie.parse(s) cookie = Cookie('color', 'blue') with self.assertRaises(ValueError): @@ -288,7 +288,7 @@ class TestInvalidAttributes(unittest.TestCase): # Invalid Expires s = 'color=blue; Expires=Sun, 06 Xxx 1994 08:49:37 GMT' with self.assertRaises(ValueError): - cookies = Cookie.parse(s) + Cookie.parse(s) cookie = Cookie('color', 'blue') with self.assertRaises(ValueError): diff --git a/ipatests/test_ipapython/test_dn.py b/ipatests/test_ipapython/test_dn.py index e09186f85..a96bd33c5 100644 --- a/ipatests/test_ipapython/test_dn.py +++ b/ipatests/test_ipapython/test_dn.py @@ -933,7 +933,7 @@ class TestDN(unittest.TestCase): dn3[1.0] # pylint: disable=pointless-statement def test_assignments(self): - dn = dn2 = DN('t=0,t=1,t=2,t=3,t=4,t=5,t=6,t=7,t=8,t=9') + dn = DN('t=0,t=1,t=2,t=3,t=4,t=5,t=6,t=7,t=8,t=9') with self.assertRaises(TypeError): dn[0] = RDN('t=a') with self.assertRaises(TypeError): diff --git a/ipatests/test_ipapython/test_ipautil.py b/ipatests/test_ipapython/test_ipautil.py index d0a68dfa3..6427935b1 100644 --- a/ipatests/test_ipapython/test_ipautil.py +++ b/ipatests/test_ipapython/test_ipautil.py @@ -183,7 +183,6 @@ class TestCIDict(object): self.cidict.keys(), self.cidict.values())) def test_iter(self): - items = [] assert list(self.cidict) == list(self.cidict.keys()) assert sorted(self.cidict) == sorted(['Key1', 'key2', 'KEY3']) diff --git a/ipatests/test_ipapython/test_keyring.py b/ipatests/test_ipapython/test_keyring.py index c81e6d95f..cd3d1f19b 100644 --- a/ipatests/test_ipapython/test_keyring.py +++ b/ipatests/test_ipapython/test_keyring.py @@ -111,7 +111,7 @@ class test_keyring(object): """ Read a non-existent key """ - result = kernel_keyring.read_key(TEST_KEY) + kernel_keyring.read_key(TEST_KEY) def test_06(self): """ diff --git a/ipatests/test_ipaserver/test_otptoken_import.py b/ipatests/test_ipaserver/test_otptoken_import.py index ba7c3c8b0..f1b4331df 100644 --- a/ipatests/test_ipaserver/test_otptoken_import.py +++ b/ipatests/test_ipaserver/test_otptoken_import.py @@ -102,7 +102,7 @@ class test_otptoken_import(object): def test_figure8(self): nss.nss_init_nodb() try: - doc = PSKCDocument(os.path.join(basename, "pskc-figure8.xml")) + PSKCDocument(os.path.join(basename, "pskc-figure8.xml")) except NotImplementedError: # X.509 is not supported. pass else: @@ -113,7 +113,7 @@ class test_otptoken_import(object): def test_invalid(self): nss.nss_init_nodb() try: - doc = PSKCDocument(os.path.join(basename, "pskc-invalid.xml")) + PSKCDocument(os.path.join(basename, "pskc-invalid.xml")) except ValueError: # File is invalid. pass else: diff --git a/ipatests/test_pkcs10/test_pkcs10.py b/ipatests/test_pkcs10/test_pkcs10.py index 4c5e09d04..152d8e766 100644 --- a/ipatests/test_pkcs10/test_pkcs10.py +++ b/ipatests/test_pkcs10/test_pkcs10.py @@ -111,7 +111,7 @@ class test_update(object): csr = self.read_file("test3.csr") try: - request = pkcs10.load_certificate_request(csr) + pkcs10.load_certificate_request(csr) except NSPRError as nsprerr: # (SEC_ERROR_BAD_DER) security library: improperly formatted DER-encoded message. assert(nsprerr. errno== -8183) @@ -122,6 +122,6 @@ class test_update(object): """ csr = self.read_file("test4.csr") try: - request = pkcs10.load_certificate_request(csr) + pkcs10.load_certificate_request(csr) except (TypeError, binascii.Error) as typeerr: assert(str(typeerr) == 'Incorrect padding') diff --git a/ipatests/test_webui/test_host.py b/ipatests/test_webui/test_host.py index a87d50989..0fced0423 100644 --- a/ipatests/test_webui/test_host.py +++ b/ipatests/test_webui/test_host.py @@ -134,7 +134,6 @@ class test_host(host_tasks): self.init_app() # ENHANCEMENT: generate csr dynamically csr = self.load_file(csr_path) - realm = self.config.get('ipa_realm') cert_widget_sel = "div.certificate-widget" self.add_record(ENTITY, self.data) @@ -229,7 +228,6 @@ class test_host(host_tasks): self.init_app() cert = self.load_file(cert_path) - realm = self.config.get('ipa_realm') self.add_record(ENTITY, self.data) self.navigate_to_record(self.pkey) diff --git a/ipatests/test_webui/test_idviews.py b/ipatests/test_webui/test_idviews.py index b7f5c312e..7e7d90564 100644 --- a/ipatests/test_webui/test_idviews.py +++ b/ipatests/test_webui/test_idviews.py @@ -106,7 +106,6 @@ class test_idviews(UI_driver): self.navigate_to_record(idview.PKEY) self.switch_to_facet(idview.HOST_FACET) - parent_entity = 'idview' # apply to host self.add_associations( diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/test_range.py index 35d2d60d9..bc0732510 100644 --- a/ipatests/test_webui/test_range.py +++ b/ipatests/test_webui/test_range.py @@ -59,9 +59,6 @@ class test_range(range_tasks): pkey_local = 'itest-local' pkey_ad = 'itest-ad' - pkey_posix = 'itest-ad-posix' - pkey_winsync = 'itest-ad-winsync' - pkey_trust = 'itest-ipa-trust' column = 'iparangetype' add = self.get_add_data(pkey_local) diff --git a/ipatests/test_webui/test_service.py b/ipatests/test_webui/test_service.py index 5b1849bae..602ae4d83 100644 --- a/ipatests/test_webui/test_service.py +++ b/ipatests/test_webui/test_service.py @@ -93,8 +93,6 @@ class test_service(sevice_tasks): data = self.prep_data() pkey = data.get('pkey') csr = self.load_file(csr_path) - host = self.config.get('ipa_server') - realm = self.config.get('ipa_realm') cert_widget_sel = "div.certificate-widget" self.add_record(ENTITY, data) @@ -190,7 +188,6 @@ class test_service(sevice_tasks): data = self.prep_data() pkey = data.get('pkey') cert = self.load_file(cert_path) - realm = self.config.get('ipa_realm') cert_widget_sel = "div.certificate-widget" self.add_record(ENTITY, data) diff --git a/ipatests/test_webui/test_user.py b/ipatests/test_webui/test_user.py index a1fc7076a..c58e0eda1 100644 --- a/ipatests/test_webui/test_user.py +++ b/ipatests/test_webui/test_user.py @@ -190,7 +190,6 @@ class test_user(user_tasks): self.init_app() # ENHANCEMENT: generate csr dynamically csr = self.load_file(csr_path) - realm = self.config.get('ipa_realm') cert_widget_sel = "div.certificate-widget" self.add_record(user.ENTITY, user.DATA) diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index ab917d849..d581ad4a9 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -306,7 +306,7 @@ class UI_driver(object): """ runner = self - for i in range(n): + for _i in range(n): self.wait(implicit) WebDriverWait(self.driver, self.request_timeout).until_not(lambda d: runner.has_active_request()) self.wait() @@ -1499,7 +1499,7 @@ class UI_driver(object): # add values for t in tables: - table, keys, exts = get_t_vals(t) + table, keys, _exts = get_t_vals(t) # add one by one to test for #3711 for key in keys: self.add_table_associations(table, [key]) @@ -1517,7 +1517,7 @@ class UI_driver(object): p = self.get_form() # now tables in categories should be empty, check it for t in tables: - table, keys, exts = get_t_vals(t) + table, keys, _exts = get_t_vals(t) if table in no_categories: # clear the rest self.delete_record(keys, None, p, table) @@ -1534,7 +1534,7 @@ class UI_driver(object): self.assert_rule_tables_enabled(t_list, True) for t in tables: - table, keys, exts = get_t_vals(t) + table, keys, _exts = get_t_vals(t) # add multiple at once and test table delete button self.add_table_associations(table, keys, delete=True) @@ -1678,7 +1678,7 @@ class UI_driver(object): """ if not parent: parent = self.get_form() - el = self.find(selector, By.CSS_SELECTOR, parent, strict=True) + self.find(selector, By.CSS_SELECTOR, parent, strict=True) dis = self.find(selector+"[disabled]", By.CSS_SELECTOR, parent) if negative: assert dis is None, "Element is disabled: %s" % selector diff --git a/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py b/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py index 014d088c6..edc97f07b 100644 --- a/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py +++ b/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py @@ -90,13 +90,13 @@ class CertManipCmdTestBase(XMLRPC_test): # list of certificates to add to entry cls.certs = [ get_testcert(DN(('CN', cls.entity_subject)), cls.entity_principal) - for i in range(3) + for _i in range(3) ] # list of certificates for testing of removal of non-existent certs cls.nonexistent_certs = [ get_testcert(DN(('CN', cls.entity_subject)), cls.entity_principal) - for j in range(2) + for _j in range(2) ] # cert subset to remove from entry diff --git a/ipatests/test_xmlrpc/test_automount_plugin.py b/ipatests/test_xmlrpc/test_automount_plugin.py index 9379b53ac..e3ad8b49d 100644 --- a/ipatests/test_xmlrpc/test_automount_plugin.py +++ b/ipatests/test_xmlrpc/test_automount_plugin.py @@ -184,7 +184,8 @@ class test_automount(AutomountTest): """ Test adding a duplicate key using `xmlrpc.automountkey_add` method. """ - res = api.Command['automountkey_add'](self.locname, self.mapname, **self.key_kw) + api.Command['automountkey_add']( + self.locname, self.mapname, **self.key_kw) def test_5_automountmap_show(self): """ @@ -368,7 +369,8 @@ class test_automount_direct(AutomountTest): """ Test adding a duplicate direct map. """ - res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.direct_kw)['result'] + api.Command['automountmap_add_indirect']( + self.locname, self.mapname, **self.direct_kw) def test_2a_automountmap_tofiles(self): """Test the `automountmap_tofiles` command""" diff --git a/ipatests/test_xmlrpc/test_baseldap_plugin.py b/ipatests/test_xmlrpc/test_baseldap_plugin.py index 50a9f1eb6..2ea28795e 100644 --- a/ipatests/test_xmlrpc/test_baseldap_plugin.py +++ b/ipatests/test_xmlrpc/test_baseldap_plugin.py @@ -53,7 +53,8 @@ def test_exc_wrapper(): # Test with one callback first @test_callback.register_exc_callback - def handle_exception(self, keys, options, e, call_func, *args, **kwargs): + def handle_exception( # pylint: disable=unused-variable + self, keys, options, e, call_func, *args, **kwargs): assert args == (1, 2) assert kwargs == dict(a=1, b=2) handled_exceptions.append(type(e)) @@ -150,7 +151,8 @@ def test_exc_callback_registration(): pass @callbacktest_subclass.register_exc_callback - def exc_callback(self, keys, options, exc, call_func, *args, **kwargs): + def exc_callback( # pylint: disable=unused-variable + self, keys, options, exc, call_func, *args, **kwargs): """Subclass's private exception callback""" messages.append('Subclass registered callback') raise exc @@ -163,7 +165,8 @@ def test_exc_callback_registration(): @callbacktest_base.register_exc_callback - def exc_callback_2(self, keys, options, exc, call_func, *args, **kwargs): + def exc_callback_2( # pylint: disable=unused-variable + self, keys, options, exc, call_func, *args, **kwargs): """Callback on super class; doesn't affect the subclass""" messages.append('Superclass registered callback') raise exc diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py index ab09d0aa4..f07bb1791 100644 --- a/ipatests/test_xmlrpc/test_cert_plugin.py +++ b/ipatests/test_xmlrpc/test_cert_plugin.py @@ -141,11 +141,11 @@ class test_cert(XMLRPC_test): This should fail because the service principal doesn't exist """ # First create the host that will use this policy - res = api.Command['host_add'](self.host_fqdn, force= True)['result'] + assert 'result' in api.Command['host_add'](self.host_fqdn, force=True) csr = unicode(self.generateCSR(str(self.subject))) with assert_raises(errors.NotFound): - res = api.Command['cert_request'](csr, principal=self.service_princ) + api.Command['cert_request'](csr, principal=self.service_princ) def test_0002_cert_add(self): """ @@ -267,7 +267,7 @@ class test_cert_find(XMLRPC_test): """ Search for the OCSP certificate. """ - res = api.Command['cert_find'](subject=u'OCSP Subsystem') + api.Command['cert_find'](subject=u'OCSP Subsystem') def test_0004_find_this_host(self): """ @@ -458,7 +458,7 @@ class test_cert_find(XMLRPC_test): """ Search with a negative sizelimit """ - res = api.Command['cert_find'](sizelimit=-100) + api.Command['cert_find'](sizelimit=-100) def test_0029_search_for_notfound(self): """ @@ -479,4 +479,4 @@ class test_cert_find(XMLRPC_test): """ Search using invalid date format """ - res = api.Command['cert_find'](issuedon_from=u'xyz') + api.Command['cert_find'](issuedon_from=u'xyz') diff --git a/ipatests/test_xmlrpc/test_hbac_plugin.py b/ipatests/test_xmlrpc/test_hbac_plugin.py index 55b038754..75c15c5ab 100644 --- a/ipatests/test_xmlrpc/test_hbac_plugin.py +++ b/ipatests/test_xmlrpc/test_hbac_plugin.py @@ -268,7 +268,7 @@ class test_hbac(XMLRPC_test): """ Test deprecated command hbacrule_add_sourcehost. """ - ret = api.Command['hbacrule_add_sourcehost']( + api.Command['hbacrule_add_sourcehost']( self.rule_name, host=self.test_host, hostgroup=self.test_hostgroup ) @@ -307,7 +307,7 @@ class test_hbac(XMLRPC_test): """ Test deprecated command hbacrule_remove_sourcehost. """ - ret = api.Command['hbacrule_remove_sourcehost']( + api.Command['hbacrule_remove_sourcehost']( self.rule_name, host=self.test_host, hostgroup=self.test_hostgroup ) @@ -316,7 +316,7 @@ class test_hbac(XMLRPC_test): """ Test adding the same external host using `xmlrpc.hbacrule_add_host`. """ - ret = api.Command['hbacrule_mod']( + api.Command['hbacrule_mod']( self.rule_name, setattr=self.test_invalid_sourcehost ) diff --git a/ipatests/test_xmlrpc/test_hbactest_plugin.py b/ipatests/test_xmlrpc/test_hbactest_plugin.py index bad59f4c8..12ecfc338 100644 --- a/ipatests/test_xmlrpc/test_hbactest_plugin.py +++ b/ipatests/test_xmlrpc/test_hbactest_plugin.py @@ -91,20 +91,20 @@ class test_hbactest(XMLRPC_test): self.rule_names[i], accessruletype=self.rule_type, description=self.rule_descs[i], ) - ret = api.Command['hbacrule_add_user']( + api.Command['hbacrule_add_user']( self.rule_names[i], user=self.test_user, group=self.test_group ) - ret = api.Command['hbacrule_add_host']( + api.Command['hbacrule_add_host']( self.rule_names[i], host=self.test_host, hostgroup=self.test_hostgroup ) - ret = api.Command['hbacrule_add_service']( + api.Command['hbacrule_add_service']( self.rule_names[i], hbacsvc=self.test_service ) if i & 1: - ret = api.Command['hbacrule_disable'](self.rule_names[i]) + api.Command['hbacrule_disable'](self.rule_names[i]) def test_a_hbactest_check_rules_detail(self): """ diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py index 279186b70..b36c6b812 100644 --- a/ipatests/test_xmlrpc/test_host_plugin.py +++ b/ipatests/test_xmlrpc/test_host_plugin.py @@ -619,9 +619,9 @@ class TestHostDNS(XMLRPC_test): try: ipv6only_host.create(force=False) finally: - command = ipv6only_host.run_command('dnsrecord_del', dnszone, - ipv6only_host.shortname, - aaaarecord=aaaarec) + ipv6only_host.run_command( + 'dnsrecord_del', dnszone, ipv6only_host.shortname, + aaaarecord=aaaarec) def test_add_ipv4only_host(self, dns_setup, ipv4only_host): ipv4only_host.run_command('dnsrecord_add', dnszone, @@ -629,9 +629,9 @@ class TestHostDNS(XMLRPC_test): try: ipv4only_host.create(force=False) finally: - command = ipv4only_host.run_command('dnsrecord_del', dnszone, - ipv4only_host.shortname, - arecord=arec) + ipv4only_host.run_command( + 'dnsrecord_del', dnszone, ipv4only_host.shortname, + arecord=arec) def test_add_ipv46both_host(self, dns_setup, ipv46both_host): ipv46both_host.run_command('dnsrecord_add', dnszone, @@ -640,10 +640,9 @@ class TestHostDNS(XMLRPC_test): try: ipv46both_host.create(force=False) finally: - command = ipv46both_host.run_command('dnsrecord_del', dnszone, - ipv46both_host.shortname, - arecord=arec2, - aaaarecord=aaaarec2) + ipv46both_host.run_command( + 'dnsrecord_del', dnszone, ipv46both_host.shortname, + arecord=arec2, aaaarecord=aaaarec2) def test_add_ipv4_host_from_ip(self, dns_setup, ipv4_fromip_host): ipv4_fromip_host.ensure_missing() diff --git a/ipatests/test_xmlrpc/test_permission_plugin.py b/ipatests/test_xmlrpc/test_permission_plugin.py index fe4a5b959..6336df7c1 100644 --- a/ipatests/test_xmlrpc/test_permission_plugin.py +++ b/ipatests/test_xmlrpc/test_permission_plugin.py @@ -138,7 +138,7 @@ def lineinfo(level): # Including this info in the test name makes it possible # to locate failing tests. frame = inspect.currentframe() - for i in range(level): + for _i in range(level): frame = frame.f_back lineno = frame.f_lineno filename = os.path.basename(frame.f_code.co_filename) @@ -3455,9 +3455,8 @@ class test_managed_permissions(Declarative): ldap = ldap2(api) ldap.connect() - result = api.Command.permission_add(permission1, type=u'user', - ipapermright=u'write', - attrs=[u'cn']) + api.Command.permission_add( + permission1, type=u'user', ipapermright=u'write', attrs=[u'cn']) # TODO: This hack relies on the permission internals. # Change as necessary. @@ -3468,8 +3467,7 @@ class test_managed_permissions(Declarative): ldap.update_entry(entry) # Update the ACI via the API - result = api.Command.permission_mod(permission1, - attrs=[u'l', u'o', u'cn']) + api.Command.permission_mod(permission1, attrs=[u'l', u'o', u'cn']) # Set the permission type to MANAGED entry = ldap.get_entry(permission1_dn) diff --git a/ipatests/test_xmlrpc/test_pwpolicy_plugin.py b/ipatests/test_xmlrpc/test_pwpolicy_plugin.py index 381674608..239ce5b7d 100644 --- a/ipatests/test_xmlrpc/test_pwpolicy_plugin.py +++ b/ipatests/test_xmlrpc/test_pwpolicy_plugin.py @@ -163,7 +163,8 @@ class test_pwpolicy(XMLRPC_test): Test adding password policy to a managed group. """ try: - entry = api.Command['pwpolicy_add'](self.user, krbminpwdlife=50, cospriority=2)['result'] + api.Command['pwpolicy_add']( + self.user, krbminpwdlife=50, cospriority=2) except errors.ManagedPolicyError: pass else: diff --git a/ipatests/test_xmlrpc/testcert.py b/ipatests/test_xmlrpc/testcert.py index b7abcdcec..def820f16 100644 --- a/ipatests/test_xmlrpc/testcert.py +++ b/ipatests/test_xmlrpc/testcert.py @@ -93,10 +93,6 @@ def makecert(reqdir, subject, principal): # Generate NSS cert database to store the private key for our CSR run_certutil(reqdir, ["-N", "-f", pwname]) - res = api.Command['config_show']() - subject_base = res['result']['ipacertificatesubjectbase'][0] - - cert = None csr = unicode(generate_csr(reqdir, pwname, str(subject))) res = api.Command['cert_request'](csr, principal=principal, add=True) diff --git a/ipatests/test_xmlrpc/tracker/automember_plugin.py b/ipatests/test_xmlrpc/tracker/automember_plugin.py index 61f87c365..151668945 100644 --- a/ipatests/test_xmlrpc/tracker/automember_plugin.py +++ b/ipatests/test_xmlrpc/tracker/automember_plugin.py @@ -110,7 +110,7 @@ class AutomemberTracker(Tracker): try: self.attrs[u'group'] =\ self.attrs[u'group'] + [options[u'group']] - except KeyError as ex: + except KeyError: self.attrs[u'group'] = [options[u'group']] # search for hosts in the target automember and # add them as memberindirect hosts @@ -118,7 +118,7 @@ class AutomemberTracker(Tracker): try: self.attrs[u'hostgroup'] =\ self.attrs[u'hostgroup'] + [options[u'hostgroup']] - except KeyError as ex: + except KeyError: self.attrs[u'hostgroup'] = [options[u'hostgroup']] command = self.make_add_member_command(options) @@ -135,12 +135,12 @@ class AutomemberTracker(Tracker): try: if not self.attrs[u'member_host']: del self.attrs[u'member_host'] - except KeyError as ex: + except KeyError: pass try: if not self.attrs[u'member_automember']: del self.attrs[u'member_automember'] - except KeyError as ex: + except KeyError: pass command = self.make_remove_member_command(options) diff --git a/ipatests/test_xmlrpc/tracker/group_plugin.py b/ipatests/test_xmlrpc/tracker/group_plugin.py index 94a4cdc8c..5d039d441 100644 --- a/ipatests/test_xmlrpc/tracker/group_plugin.py +++ b/ipatests/test_xmlrpc/tracker/group_plugin.py @@ -117,13 +117,13 @@ class GroupTracker(Tracker): try: self.attrs[u'member_user'] =\ self.attrs[u'member_user'] + [options[u'user']] - except KeyError as ex: + except KeyError: self.attrs[u'member_user'] = [options[u'user']] elif u'group' in options: try: self.attrs[u'member_group'] =\ self.attrs[u'member_group'] + [options[u'group']] - except KeyError as ex: + except KeyError: self.attrs[u'member_group'] = [options[u'group']] command = self.make_add_member_command(options) @@ -140,12 +140,12 @@ class GroupTracker(Tracker): try: if not self.attrs[u'member_user']: del self.attrs[u'member_user'] - except KeyError as ex: + except KeyError: pass try: if not self.attrs[u'member_group']: del self.attrs[u'member_group'] - except KeyError as ex: + except KeyError: pass command = self.make_remove_member_command(options) diff --git a/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py b/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py index 8b63c90b0..080d0120a 100644 --- a/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py +++ b/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py @@ -91,7 +91,7 @@ class HostGroupTracker(Tracker): try: self.attrs[u'member_host'] =\ self.attrs[u'member_host'] + [options[u'host']] - except KeyError as ex: + except KeyError: self.attrs[u'member_host'] = [options[u'host']] # search for hosts in the target hostgroup and # add them as memberindirect hosts @@ -99,7 +99,7 @@ class HostGroupTracker(Tracker): try: self.attrs[u'member_hostgroup'] =\ self.attrs[u'member_hostgroup'] + [options[u'hostgroup']] - except KeyError as ex: + except KeyError: self.attrs[u'member_hostgroup'] = [options[u'hostgroup']] command = self.make_add_member_command(options) @@ -116,12 +116,12 @@ class HostGroupTracker(Tracker): try: if not self.attrs[u'member_host']: del self.attrs[u'member_host'] - except KeyError as ex: + except KeyError: pass try: if not self.attrs[u'member_hostgroup']: del self.attrs[u'member_hostgroup'] - except KeyError as ex: + except KeyError: pass command = self.make_remove_member_command(options) diff --git a/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py b/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py index f7440540c..a571974c5 100644 --- a/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py +++ b/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py @@ -88,7 +88,7 @@ class SudoCmdGroupTracker(Tracker): try: self.attrs[u'member_sudocmd'] =\ self.attrs[u'member_sudocmd'] + [options[u'sudocmd']] - except KeyError as ex: + except KeyError: self.attrs[u'member_sudocmd'] = [options[u'sudocmd']] command = self.make_add_member_command(options) @@ -102,7 +102,7 @@ class SudoCmdGroupTracker(Tracker): try: if not self.attrs[u'member_sudocmd']: del self.attrs[u'member_sudocmd'] - except KeyError as ex: + except KeyError: pass command = self.make_remove_member_command(options) diff --git a/ipatests/test_xmlrpc/tracker/user_plugin.py b/ipatests/test_xmlrpc/tracker/user_plugin.py index 6bc0ce19c..4485fd9b4 100644 --- a/ipatests/test_xmlrpc/tracker/user_plugin.py +++ b/ipatests/test_xmlrpc/tracker/user_plugin.py @@ -165,7 +165,7 @@ class UserTracker(KerberosAliasMixin, Tracker): (self.kwargs[key].split('@'))[0].lower(), (self.kwargs[key].split('@'))[1] )] - except IndexError as ex: + except IndexError: # we can provide just principal part self.attrs[key] = [u'%s@%s' % ( (self.kwargs[key].lower(), diff --git a/ipatests/util.py b/ipatests/util.py index 8878993e1..0b50f8554 100644 --- a/ipatests/util.py +++ b/ipatests/util.py @@ -604,7 +604,7 @@ class DummyClass(object): def __init__(self, *calls): self.__calls = calls self.__i = 0 - for (name, args, kw, result) in calls: + for (name, _args, _kw, _result) in calls: method = DummyMethod(self.__process, name) setattr(self, name, method) |