mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-11-02 20:30:26 -06:00
Use os.path.isfile() and isdir()
Replace custom file_exists() and dir_exists() functions with proper functions from Python's stdlib. The change also gets rid of pylint's invalid bad-python3-import error, https://github.com/PyCQA/pylint/issues/1565 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
1 parent
fad88b358b
commit
b29db07c3b
26 files changed
+57
-78
No files matched your search
@@ -30,7 +30,7 @@ from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipaserver.install.ldapupdate import LDAPUpdate, BadSyntax
|
||||
from ipaserver.install import installutils
|
||||
from ipapython import ipautil, ipaldap
|
||||
from ipapython import ipaldap
|
||||
from ipaplatform.paths import paths
|
||||
from ipapython.dn import DN
|
||||
|
||||
@@ -56,7 +56,7 @@ class test_update(unittest.TestCase):
|
||||
def setUp(self):
|
||||
fqdn = installutils.get_fqdn()
|
||||
pwfile = api.env.dot_ipa + os.sep + ".dmpw"
|
||||
if ipautil.file_exists(pwfile):
|
||||
if os.path.isfile(pwfile):
|
||||
fp = open(pwfile, "r")
|
||||
self.dm_password = fp.read().rstrip()
|
||||
fp.close()
|
||||
@@ -68,7 +68,7 @@ class test_update(unittest.TestCase):
|
||||
self.ld.simple_bind(bind_dn=ipaldap.DIRMAN_DN,
|
||||
bind_password=self.dm_password)
|
||||
self.testdir = os.path.abspath(os.path.dirname(__file__))
|
||||
if not ipautil.file_exists(os.path.join(self.testdir,
|
||||
if not os.path.isfile(os.path.join(self.testdir,
|
||||
"0_reset.update")):
|
||||
raise nose.SkipTest("Unable to find test update files")
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import pytest
|
||||
from ipatests.i18n import create_po, po_file_iterate
|
||||
from ipalib.request import context
|
||||
from ipalib import text
|
||||
from ipapython.ipautil import file_exists
|
||||
|
||||
if six.PY3:
|
||||
unicode = str
|
||||
@@ -106,11 +105,11 @@ class test_TestLang(object):
|
||||
raise nose.SkipTest('Unable to create po file "%s" & mo file "%s" from pot file "%s"' %
|
||||
(self.po_file, self.mo_file, self.pot_file))
|
||||
|
||||
if not file_exists(self.po_file):
|
||||
if not os.path.isfile(self.po_file):
|
||||
raise nose.SkipTest(
|
||||
'Test po file unavailable: {}'.format(self.po_file))
|
||||
|
||||
if not file_exists(self.mo_file):
|
||||
if not os.path.isfile(self.mo_file):
|
||||
raise nose.SkipTest(
|
||||
'Test mo file unavailable: {}'.format(self.mo_file))
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import six
|
||||
from ipaplatform.paths import paths
|
||||
from ipaserver.plugins.ldap2 import ldap2, AUTOBIND_DISABLED
|
||||
from ipalib import api, create_api, errors
|
||||
from ipapython import ipautil
|
||||
from ipapython.dn import DN
|
||||
|
||||
if six.PY3:
|
||||
@@ -85,7 +84,7 @@ class test_ldap(object):
|
||||
Test a simple LDAP bind using ldap2
|
||||
"""
|
||||
pwfile = api.env.dot_ipa + os.sep + ".dmpw"
|
||||
if ipautil.file_exists(pwfile):
|
||||
if os.path.isfile(pwfile):
|
||||
with open(pwfile, "r") as fp:
|
||||
dm_password = fp.read().rstrip()
|
||||
else:
|
||||
@@ -109,7 +108,7 @@ class test_ldap(object):
|
||||
myapi.finalize()
|
||||
|
||||
pwfile = api.env.dot_ipa + os.sep + ".dmpw"
|
||||
if ipautil.file_exists(pwfile):
|
||||
if os.path.isfile(pwfile):
|
||||
with open(pwfile, "r") as fp:
|
||||
dm_password = fp.read().rstrip()
|
||||
else:
|
||||
|
||||
@@ -6,7 +6,6 @@ import io
|
||||
import os
|
||||
from ipaserver.plugins.ldap2 import ldap2
|
||||
from ipalib import api
|
||||
from ipapython import ipautil
|
||||
from ipapython.dn import DN
|
||||
import pytest
|
||||
|
||||
@@ -31,7 +30,7 @@ class TestTopologyPlugin(object):
|
||||
if self.conn and self.conn.isconnected():
|
||||
self.conn.disconnect()
|
||||
|
||||
@pytest.mark.skipif(ipautil.file_exists(pwfile) is False,
|
||||
@pytest.mark.skipif(os.path.isfile(pwfile) is False,
|
||||
reason="You did not provide a .dmpw file with the DM password")
|
||||
def test_topologyplugin(self):
|
||||
pluginattrs = {
|
||||
|
||||
@@ -22,7 +22,6 @@ Test the `pkcs10.py` module.
|
||||
|
||||
import nose
|
||||
from ipalib import pkcs10
|
||||
from ipapython import ipautil
|
||||
import pytest
|
||||
import os
|
||||
import cryptography.x509
|
||||
@@ -36,7 +35,7 @@ class test_update(object):
|
||||
|
||||
def setup(self):
|
||||
self.testdir = os.path.abspath(os.path.dirname(__file__))
|
||||
if not ipautil.file_exists(os.path.join(self.testdir,
|
||||
if not os.path.isfile(os.path.join(self.testdir,
|
||||
"test0.csr")):
|
||||
raise nose.SkipTest("Unable to find test update files")
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def is_db_configured():
|
||||
aliasdir = api.env.dot_ipa + os.sep + 'alias' + os.sep + '.pwd'
|
||||
|
||||
if (api.env.xmlrpc_uri == u'http://localhost:8888/ipa/xml' and
|
||||
not ipautil.file_exists(aliasdir)):
|
||||
not os.path.isfile(aliasdir)):
|
||||
raise nose.SkipTest('developer CA not configured in %s' % aliasdir)
|
||||
|
||||
# Test setup
|
||||
|
||||
Reference in new issue
Block a user