mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
pylint: Synchronize pylint plugin to ipatests code
Pylint is a static analysis tool and therefore, couldn't always analyze dynamic stuff properly. Transformation plugins is a way to teach Pylint how to handle such cases. Particularly, with the help of FreeIPA own plugin, it is possible to tell Pylint about instance fields having a duck-typing nature. A drawback exposed here is that a static view (Pylint's) of code should be consistent with an actual one, otherwise, codebase will be polluted with various skips of pylint checks. * added missing fields to ipatests.test_integration.base.IntegrationTest * an attempt is made to clear `no-member` skips for ipatests * removed no longer needed `pytest` module transformation Related: https://pagure.io/freeipa/issue/8116 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
92b440a0ba
commit
e128e7d691
@@ -1873,7 +1873,7 @@ def ldapmodify_dm(host, ldif_text, **kwargs):
|
||||
args = [
|
||||
'ldapmodify',
|
||||
'-x',
|
||||
'-D', str(host.config.dirman_dn), # pylint: disable=no-member
|
||||
'-D', str(host.config.dirman_dn),
|
||||
'-w', host.config.dirman_password
|
||||
]
|
||||
return host.run_command(args, stdin_text=ldif_text, **kwargs)
|
||||
@@ -1894,7 +1894,7 @@ def ldapsearch_dm(host, base, ldap_args, scope='sub', **kwargs):
|
||||
'-x', '-ZZ',
|
||||
'-h', host.hostname,
|
||||
'-p', '389',
|
||||
'-D', str(host.config.dirman_dn), # pylint: disable=no-member
|
||||
'-D', str(host.config.dirman_dn),
|
||||
'-w', host.config.dirman_password,
|
||||
'-s', scope,
|
||||
'-b', base,
|
||||
|
@@ -54,23 +54,19 @@ def pytest_configure(config):
|
||||
capture = config.pluginmanager.getplugin('capturemanager')
|
||||
orig_stdout, orig_stderr = sys.stdout, sys.stderr
|
||||
if capture:
|
||||
# pylint: disable=no-member
|
||||
if hasattr(capture, 'suspend_global_capture'):
|
||||
# pytest >= 3.3
|
||||
capture.suspend_global_capture()
|
||||
else:
|
||||
# legacy support for pytest <= 3.2 (Fedora 27)
|
||||
capture._capturing.suspend_capturing()
|
||||
# pylint: enable=no-member
|
||||
sys.stderr.write(self.format(record))
|
||||
sys.stderr.write('\n')
|
||||
if capture:
|
||||
# pylint: disable=no-member
|
||||
if hasattr(capture, 'resume_global_capture'):
|
||||
capture.resume_global_capture()
|
||||
else:
|
||||
capture._capturing.resume_capturing()
|
||||
# pylint: enable=no-member
|
||||
sys.stdout, sys.stderr = orig_stdout, orig_stderr
|
||||
|
||||
level = convert_log_level(config.getoption('logging_level'))
|
||||
|
@@ -17,9 +17,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# FIXME: Pylint errors
|
||||
# pylint: disable=no-member
|
||||
|
||||
import re
|
||||
|
||||
from ipalib.constants import IPAAPI_USER
|
||||
|
@@ -183,7 +183,7 @@ class TestIPACommand(IntegrationTest):
|
||||
raiseonerr=False
|
||||
)
|
||||
assert result.returncode == 2
|
||||
err = result.stderr_text.strip() # pylint: disable=no-member
|
||||
err = result.stderr_text.strip()
|
||||
assert err == "ipa: ERROR: loc: privilege not found"
|
||||
# add privilege
|
||||
result = self.master.run_command(
|
||||
@@ -206,7 +206,7 @@ class TestIPACommand(IntegrationTest):
|
||||
|
||||
master = self.master
|
||||
|
||||
base_dn = str(master.domain.basedn) # pylint: disable=no-member
|
||||
base_dn = str(master.domain.basedn)
|
||||
entry_ldif = textwrap.dedent("""
|
||||
dn: uid=system,cn=sysaccounts,cn=etc,{base_dn}
|
||||
changetype: add
|
||||
@@ -225,7 +225,7 @@ class TestIPACommand(IntegrationTest):
|
||||
new_passwd, master)
|
||||
|
||||
def get_krbinfo(self, user):
|
||||
base_dn = str(self.master.domain.basedn) # pylint: disable=no-member
|
||||
base_dn = str(self.master.domain.basedn)
|
||||
result = tasks.ldapsearch_dm(
|
||||
self.master,
|
||||
'uid={user},cn=users,cn=accounts,{base_dn}'.format(
|
||||
@@ -248,7 +248,7 @@ class TestIPACommand(IntegrationTest):
|
||||
new_passwd = 'userPasswd123'
|
||||
new_passwd2 = 'mynewPwd123'
|
||||
master = self.master
|
||||
base_dn = str(master.domain.basedn) # pylint: disable=no-member
|
||||
base_dn = str(master.domain.basedn)
|
||||
|
||||
# Create a user with a password
|
||||
tasks.kinit_admin(master)
|
||||
@@ -293,7 +293,7 @@ class TestIPACommand(IntegrationTest):
|
||||
time.sleep(1)
|
||||
master.run_command([
|
||||
paths.LDAPPASSWD,
|
||||
'-D', str(master.config.dirman_dn), # pylint: disable=no-member
|
||||
'-D', str(master.config.dirman_dn),
|
||||
'-w', master.config.dirman_password,
|
||||
'-a', new_passwd,
|
||||
'-s', new_passwd2,
|
||||
@@ -376,7 +376,7 @@ class TestIPACommand(IntegrationTest):
|
||||
|
||||
test_user = 'test-ssh'
|
||||
external_master_hostname = \
|
||||
self.master.external_hostname # pylint: disable=no-member
|
||||
self.master.external_hostname
|
||||
|
||||
pub_keys = []
|
||||
|
||||
@@ -628,7 +628,7 @@ class TestIPACommand(IntegrationTest):
|
||||
dn = DN(
|
||||
('cn', 'HTTP'), ('cn', self.master.hostname), ('cn', 'masters'),
|
||||
('cn', 'ipa'), ('cn', 'etc'),
|
||||
self.master.domain.basedn # pylint: disable=no-member
|
||||
self.master.domain.basedn
|
||||
)
|
||||
|
||||
conn = self.master.ldap_connect()
|
||||
|
@@ -188,7 +188,7 @@ class TestInstallWithCA1(InstallTestBase1):
|
||||
https://pagure.io/freeipa/issue/7418
|
||||
"""
|
||||
ldap_conf = paths.OPENLDAP_LDAP_CONF
|
||||
base_dn = self.master.domain.basedn # pylint: disable=no-member
|
||||
base_dn = self.master.domain.basedn
|
||||
client = self.replicas[0]
|
||||
tasks.uninstall_master(client)
|
||||
expected_msg1 = "contains deprecated and unsupported " \
|
||||
|
@@ -54,7 +54,7 @@ class TestSMB(IntegrationTest):
|
||||
cls.clients, domain_level,
|
||||
clients_extra_args=('--mkhomedir',))
|
||||
|
||||
cls.ad = cls.ads[0] # pylint: disable=no-member
|
||||
cls.ad = cls.ads[0]
|
||||
cls.smbserver = cls.clients[0]
|
||||
cls.smbclient = cls.clients[1]
|
||||
cls.ad_user = '{}@{}'.format(cls.ad_user_login, cls.ad.domain.name)
|
||||
|
@@ -45,7 +45,7 @@ class TestSSSDWithAdTrust(IntegrationTest):
|
||||
def install(cls, mh):
|
||||
super(TestSSSDWithAdTrust, cls).install(mh)
|
||||
|
||||
cls.ad = cls.ads[0] # pylint: disable=no-member
|
||||
cls.ad = cls.ads[0]
|
||||
|
||||
tasks.install_adtrust(cls.master)
|
||||
tasks.configure_dns_for_trust(cls.master, cls.ad)
|
||||
|
@@ -724,7 +724,7 @@ class TestSudo(IntegrationTest):
|
||||
"""
|
||||
self.master.run_command(
|
||||
['ipa', 'config-mod', '--domain-resolution-order',
|
||||
self.domain.name]) # pylint: disable=no-member
|
||||
self.domain.name])
|
||||
try:
|
||||
# prepare the sudo rule: set only one user for ipasudorunas
|
||||
self.reset_rule_categories()
|
||||
@@ -741,7 +741,7 @@ class TestSudo(IntegrationTest):
|
||||
# according to listing of allowed commands
|
||||
result = self.list_sudo_commands('testuser1')
|
||||
expected_rule = ('(testuser2@%s) NOPASSWD: ALL'
|
||||
% self.domain.name) # pylint: disable=no-member
|
||||
% self.domain.name)
|
||||
assert expected_rule in result.stdout_text
|
||||
|
||||
# check that testuser1 can actually run commands as testuser2
|
||||
|
@@ -37,15 +37,15 @@ class BaseTestTrust(IntegrationTest):
|
||||
raise pytest.skip("Package samba-client not available "
|
||||
"on {}".format(cls.master.hostname))
|
||||
super(BaseTestTrust, cls).install(mh)
|
||||
cls.ad = cls.ads[0] # pylint: disable=no-member
|
||||
cls.ad = cls.ads[0]
|
||||
cls.ad_domain = cls.ad.domain.name
|
||||
tasks.install_adtrust(cls.master)
|
||||
cls.check_sid_generation()
|
||||
tasks.sync_time(cls.master, cls.ad)
|
||||
|
||||
cls.child_ad = cls.ad_subdomains[0] # pylint: disable=no-member
|
||||
cls.child_ad = cls.ad_subdomains[0]
|
||||
cls.ad_subdomain = cls.child_ad.domain.name
|
||||
cls.tree_ad = cls.ad_treedomains[0] # pylint: disable=no-member
|
||||
cls.tree_ad = cls.ad_treedomains[0]
|
||||
cls.ad_treedomain = cls.tree_ad.domain.name
|
||||
|
||||
# values used in workaround for
|
||||
|
@@ -42,7 +42,7 @@ class TestUpgrade(IntegrationTest):
|
||||
"""
|
||||
# Read the current entry from LDAP
|
||||
ldap = self.master.ldap_connect()
|
||||
basedn = self.master.domain.basedn # pylint: disable=no-member
|
||||
basedn = self.master.domain.basedn
|
||||
dn = DN(('cn', 'CAcert'), ('cn', 'ipa'), ('cn', 'etc'), basedn)
|
||||
entry = ldap.get_entry(dn) # pylint: disable=no-member
|
||||
# Extract the certificate as DER then double-encode
|
||||
|
@@ -74,7 +74,7 @@ class TestWinsyncMigrate(IntegrationTest):
|
||||
def install(cls, mh):
|
||||
super(TestWinsyncMigrate, cls).install(mh)
|
||||
|
||||
cls.ad = cls.ads[0] # pylint: disable=no-member
|
||||
cls.ad = cls.ads[0]
|
||||
cls.trust_test_user = '%s@%s' % (cls.ad_user, cls.ad.domain.name)
|
||||
tasks.configure_dns_for_trust(cls.master, cls.ad)
|
||||
tasks.install_adtrust(cls.master)
|
||||
|
@@ -22,10 +22,6 @@ Test the `ipalib.backend` module.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
# FIXME: Pylint errors
|
||||
# pylint: disable=no-member
|
||||
# pylint: disable=maybe-no-member
|
||||
|
||||
import threading
|
||||
from ipatests.util import ClassChecker, raises, create_test_api
|
||||
from ipatests.data import unicode_str
|
||||
|
@@ -21,8 +21,6 @@
|
||||
Test the `ipalib.frontend` module.
|
||||
"""
|
||||
|
||||
# FIXME: Pylint errors
|
||||
# pylint: disable=no-member
|
||||
import pytest
|
||||
import six
|
||||
|
||||
|
@@ -73,7 +73,6 @@ def test_round_trip():
|
||||
if six.PY2:
|
||||
assert_equal(dump_n_load(utf8_bytes), unicode_str)
|
||||
assert_equal(dump_n_load(unicode_str), unicode_str)
|
||||
# "Binary" is not "str". pylint: disable=no-member
|
||||
assert_equal(dump_n_load(Binary(binary_bytes)).data, binary_bytes)
|
||||
assert isinstance(dump_n_load(Binary(binary_bytes)), Binary)
|
||||
assert type(dump_n_load(b'hello')) is output_binary_type
|
||||
@@ -110,7 +109,6 @@ def test_xml_wrap():
|
||||
assert f({}, API_VERSION) == dict()
|
||||
b = f(b'hello', API_VERSION)
|
||||
assert isinstance(b, Binary)
|
||||
# "Binary" is not "dict" or "tuple". pylint: disable=no-member
|
||||
assert b.data == b'hello'
|
||||
u = f(u'hello', API_VERSION)
|
||||
assert type(u) is unicode
|
||||
|
@@ -395,8 +395,6 @@ class TestTimeParser:
|
||||
assert_equal(800000, time.microsecond)
|
||||
|
||||
def test_time_zones(self):
|
||||
# pylint: disable=no-member
|
||||
|
||||
timestr = "20051213141205Z"
|
||||
|
||||
time = ipautil.parse_generalized_time(timestr)
|
||||
|
@@ -154,7 +154,7 @@ class test_Fuzzy:
|
||||
|
||||
def test_assert_deepequal(pytestconfig):
|
||||
f = util.assert_deepequal
|
||||
try: # pylint: disable=no-member
|
||||
try:
|
||||
pretty = pytestconfig.getoption("pretty_print")
|
||||
except (AttributeError, ValueError):
|
||||
pretty = False
|
||||
|
@@ -183,9 +183,12 @@ ipa_class_members = {
|
||||
'normalizedns',
|
||||
],
|
||||
'ipatests.test_integration.base.IntegrationTest': [
|
||||
'domain',
|
||||
{'domain': [
|
||||
{'name': dir(str)},
|
||||
]},
|
||||
{'master': [
|
||||
{'config': [
|
||||
{'dirman_dn': dir(str)},
|
||||
{'dirman_password': dir(str)},
|
||||
{'admin_password': dir(str)},
|
||||
{'admin_name': dir(str)},
|
||||
@@ -197,15 +200,17 @@ ipa_class_members = {
|
||||
{'fips_mode': dir(bool)},
|
||||
]},
|
||||
{'domain': [
|
||||
{'basedn': dir(str)},
|
||||
{'realm': dir(str)},
|
||||
{'name': dir(str)},
|
||||
]},
|
||||
'hostname',
|
||||
{'external_hostname': dir(str)},
|
||||
{'hostname': dir(str)},
|
||||
'ip',
|
||||
'collect_log',
|
||||
{'run_command': [
|
||||
{'stdout_text': dir(str)},
|
||||
'stderr_text',
|
||||
{'stderr_text': dir(str)},
|
||||
'returncode',
|
||||
]},
|
||||
{'transport': ['put_file', 'file_exists']},
|
||||
@@ -216,6 +221,9 @@ ipa_class_members = {
|
||||
'replicas',
|
||||
'clients',
|
||||
'ad_domains',
|
||||
{'ads': dir(list)},
|
||||
{'ad_subdomains': dir(list)},
|
||||
{'ad_treedomains': dir(list)},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -229,18 +237,6 @@ def fix_ipa_classes(cls):
|
||||
MANAGER.register_transform(scoped_nodes.ClassDef, fix_ipa_classes)
|
||||
|
||||
|
||||
def pytest_config_transform():
|
||||
"""pylint.config attribute
|
||||
"""
|
||||
return AstroidBuilder(MANAGER).string_build(textwrap.dedent('''
|
||||
from _pytest.config import get_config
|
||||
config = get_config()
|
||||
'''))
|
||||
|
||||
|
||||
register_module_extender(MANAGER, 'pytest', pytest_config_transform)
|
||||
|
||||
|
||||
def ipaplatform_constants_transform():
|
||||
return AstroidBuilder(MANAGER).string_build(textwrap.dedent('''
|
||||
from ipaplatform.base.constants import constants
|
||||
|
Reference in New Issue
Block a user