flake8 pass

F632 use ==/!= to compare str, bytes, and int literals

Reviewed-by: Håkan Johansson <f96hajo@chalmers.se>
Reviewed-by: Giuseppe Di Natale <guss80@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: bunder2015 <omfgbunder@gmail.com>
Closes #8368
This commit is contained in:
bunder2015 2019-02-04 12:02:46 -05:00 committed by Brian Behlendorf
parent 57dc41de96
commit cca14128c9
2 changed files with 21 additions and 21 deletions

View File

@ -71,13 +71,13 @@ class Result(object):
if killed: if killed:
self.result = 'KILLED' self.result = 'KILLED'
Result.runresults['KILLED'] += 1 Result.runresults['KILLED'] += 1
elif self.returncode is 0: elif self.returncode == 0:
self.result = 'PASS' self.result = 'PASS'
Result.runresults['PASS'] += 1 Result.runresults['PASS'] += 1
elif self.returncode is 4: elif self.returncode == 4:
self.result = 'SKIP' self.result = 'SKIP'
Result.runresults['SKIP'] += 1 Result.runresults['SKIP'] += 1
elif self.returncode is not 0: elif self.returncode != 0:
self.result = 'FAIL' self.result = 'FAIL'
Result.runresults['FAIL'] += 1 Result.runresults['FAIL'] += 1
@ -278,7 +278,7 @@ class Cmd(object):
write_log(bytearray(result_line, encoding='utf-8'), LOG_FILE) write_log(bytearray(result_line, encoding='utf-8'), LOG_FILE)
if not options.quiet: if not options.quiet:
write_log(result_line, LOG_OUT) write_log(result_line, LOG_OUT)
elif options.quiet and self.result.result is not 'PASS': elif options.quiet and self.result.result != 'PASS':
write_log(result_line, LOG_OUT) write_log(result_line, LOG_OUT)
lines = sorted(self.result.stdout + self.result.stderr, lines = sorted(self.result.stdout + self.result.stderr,
@ -369,7 +369,7 @@ class Test(Cmd):
cont = True cont = True
if len(pretest.pathname): if len(pretest.pathname):
pretest.run(options) pretest.run(options)
cont = pretest.result.result is 'PASS' cont = pretest.result.result == 'PASS'
pretest.log(options) pretest.log(options)
if cont: if cont:
@ -448,7 +448,7 @@ class TestGroup(Test):
"because it failed verification.\n" % "because it failed verification.\n" %
(test, self.pathname), LOG_ERR) (test, self.pathname), LOG_ERR)
return len(self.tests) is not 0 return len(self.tests) != 0
def run(self, options): def run(self, options):
""" """
@ -470,7 +470,7 @@ class TestGroup(Test):
cont = True cont = True
if len(pretest.pathname): if len(pretest.pathname):
pretest.run(options) pretest.run(options)
cont = pretest.result.result is 'PASS' cont = pretest.result.result == 'PASS'
pretest.log(options) pretest.log(options)
for fname in self.tests: for fname in self.tests:
@ -586,7 +586,7 @@ class TestRun(object):
for prop in TestGroup.props: for prop in TestGroup.props:
for sect in ['DEFAULT', section]: for sect in ['DEFAULT', section]:
if config.has_option(sect, prop): if config.has_option(sect, prop):
if prop is "tags": if prop == "tags":
setattr(testgroup, prop, setattr(testgroup, prop,
eval(config.get(sect, prop))) eval(config.get(sect, prop)))
else: else:
@ -676,7 +676,7 @@ class TestRun(object):
return return
global LOG_FILE_OBJ global LOG_FILE_OBJ
if options.cmd is not 'wrconfig': if options.cmd != 'wrconfig':
try: try:
old = os.umask(0) old = os.umask(0)
os.makedirs(self.outputdir, mode=0o777) os.makedirs(self.outputdir, mode=0o777)
@ -712,12 +712,12 @@ class TestRun(object):
iteration += 1 iteration += 1
def summary(self): def summary(self):
if Result.total is 0: if Result.total == 0:
return 2 return 2
print('\nResults Summary') print('\nResults Summary')
for key in list(Result.runresults.keys()): for key in list(Result.runresults.keys()):
if Result.runresults[key] is not 0: if Result.runresults[key] != 0:
print('%s\t% 4d' % (key, Result.runresults[key])) print('%s\t% 4d' % (key, Result.runresults[key]))
m, s = divmod(time() - self.starttime, 60) m, s = divmod(time() - self.starttime, 60)
@ -787,7 +787,7 @@ def verify_user(user):
p = Popen(testcmd) p = Popen(testcmd)
p.wait() p.wait()
if p.returncode is not 0: if p.returncode != 0:
write_log("Warning: user '%s' cannot use passwordless sudo.\n" % user, write_log("Warning: user '%s' cannot use passwordless sudo.\n" % user,
LOG_ERR) LOG_ERR)
return False return False
@ -824,18 +824,18 @@ def fail(retstr, ret=1):
def options_cb(option, opt_str, value, parser): def options_cb(option, opt_str, value, parser):
path_options = ['runfile', 'outputdir', 'template', 'testdir'] path_options = ['runfile', 'outputdir', 'template', 'testdir']
if option.dest is 'runfile' and '-w' in parser.rargs or \ if option.dest == 'runfile' and '-w' in parser.rargs or \
option.dest is 'template' and '-c' in parser.rargs: option.dest == 'template' and '-c' in parser.rargs:
fail('-c and -w are mutually exclusive.') fail('-c and -w are mutually exclusive.')
if opt_str in parser.rargs: if opt_str in parser.rargs:
fail('%s may only be specified once.' % opt_str) fail('%s may only be specified once.' % opt_str)
if option.dest is 'runfile': if option.dest == 'runfile':
parser.values.cmd = 'rdconfig' parser.values.cmd = 'rdconfig'
if option.dest is 'template': if option.dest == 'template':
parser.values.cmd = 'wrconfig' parser.values.cmd = 'wrconfig'
if option.dest is 'tags': if option.dest == 'tags':
value = [x.strip() for x in value.split(',')] value = [x.strip() for x in value.split(',')]
setattr(parser.values, option.dest, value) setattr(parser.values, option.dest, value)
@ -904,11 +904,11 @@ def main():
options = parse_args() options = parse_args()
testrun = TestRun(options) testrun = TestRun(options)
if options.cmd is 'runtests': if options.cmd == 'runtests':
find_tests(testrun, options) find_tests(testrun, options)
elif options.cmd is 'rdconfig': elif options.cmd == 'rdconfig':
testrun.read(options) testrun.read(options)
elif options.cmd is 'wrconfig': elif options.cmd == 'wrconfig':
find_tests(testrun, options) find_tests(testrun, options)
testrun.write(options) testrun.write(options)
exit(0) exit(0)

View File

@ -312,7 +312,7 @@ def process_results(pathname):
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) is not 2: if len(sys.argv) != 2:
usage('usage: %s <pathname>' % sys.argv[0]) usage('usage: %s <pathname>' % sys.argv[0])
results = process_results(sys.argv[1]) results = process_results(sys.argv[1])