test/ files singleton-comparison

This patch change these errors in the test folder

C0121: Comparison to None should be 'expr is None' (singleton-comparison)
C0121: Comparison to None should be 'expr is not None' (singleton-comparison)
This commit is contained in:
Rodolfo García Peñas (kix) 2020-08-30 11:31:42 +02:00
parent 1a529b6b0e
commit a6abf2d36f
2 changed files with 9 additions and 9 deletions

View File

@ -54,7 +54,7 @@ class OLITestLib():
directory at a time. OLITestLib is not suited for running
several tests in parallel. The user is responsible for
cleaning that up herself."""
assert cls.cred_file != None
assert cls.cred_file is not None
# creating temporary dir for testing in same dir as credentials.conf
cls.testdir = os.path.abspath(
tempfile.mkdtemp(prefix='tmp_%s_' % suffix,
@ -69,8 +69,8 @@ class OLITestLib():
The returned config can be manipulated and then saved with
write_config_file()"""
# TODO, only do first time and cache then for subsequent calls?
assert cls.cred_file != None
assert cls.testdir != None
assert cls.cred_file is not None
assert cls.testdir is not None
config = CustomConfigParser()
config.readfp(default_conf)
default_conf.seek(0) # rewind config_file to start
@ -175,7 +175,7 @@ class OLITestLib():
"""Create empty maildir 'folder' in our test maildir
Does not fail if it already exists"""
assert cls.testdir != None
assert cls.testdir is not None
maildir = os.path.join(cls.testdir, 'mail', folder)
for subdir in ('', 'tmp', 'cur', 'new'):
try:
@ -189,7 +189,7 @@ class OLITestLib():
"""Delete maildir 'folder' in our test maildir
Does not fail if not existing"""
assert cls.testdir != None
assert cls.testdir is not None
maildir = os.path.join(cls.testdir, 'mail', folder)
shutil.rmtree(maildir, ignore_errors=True)
@ -199,7 +199,7 @@ class OLITestLib():
Use default mailfilename if not given.
Use some default content if not given"""
assert cls.testdir != None
assert cls.testdir is not None
while True: # Loop till we found a unique filename
mailfile = '{0}:2,'.format(random.randint(0, 999999999))
mailfilepath = os.path.join(cls.testdir, 'mail',
@ -219,7 +219,7 @@ Content here.''')
"""Returns the number of mails in maildir 'folder'
Counting only those in cur&new (ignoring tmp)."""
assert cls.testdir != None
assert cls.testdir is not None
maildir = os.path.join(cls.testdir, 'mail', folder)
boxes, mails = 0, 0
@ -238,7 +238,7 @@ Content here.''')
@classmethod
def get_maildir_uids(cls, folder):
"""Returns a list of maildir mail uids, 'None' if no valid uid"""
assert cls.testdir != None
assert cls.testdir is not None
mailfilepath = os.path.join(cls.testdir, 'mail', folder)
assert os.path.isdir(mailfilepath)
ret = []

View File

@ -128,7 +128,7 @@ class TestBasicFunctions(unittest.TestCase):
uids = OLITestLib.get_maildir_uids('INBOX.OLItest')
self.assertFalse(None in uids, msg="All mails should have been " + \
"assigned the IMAP's UID number, but {0} messages had no valid ID " \
.format(len([None for x in uids if x == None])))
.format(len([None for x in uids if x is None])))
def test_06_createfolders(self):
"""Test if createfolders works as expected