test/py: Quote consistency

When converting test/py from " to ', I missed a few places (or added a
few inconsistencies later). Fix these.

Note that only quotes in code are converted; double-quotes in comments
and HTML are left as-is, since English and HTML use " not '.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Stephen Warren 2016-01-26 13:41:31 -07:00 committed by Simon Glass
parent e8debf394f
commit a2ec560647
5 changed files with 42 additions and 42 deletions

View File

@ -122,7 +122,7 @@ class RunAndLog(object):
Nothing. Nothing.
""" """
msg = "+" + " ".join(cmd) + "\n" msg = '+' + ' '.join(cmd) + '\n'
if self.chained_file: if self.chained_file:
self.chained_file.write(msg) self.chained_file.write(msg)
self.logfile.write(self, msg) self.logfile.write(self, msg)
@ -202,19 +202,19 @@ class Logfile(object):
Nothing. Nothing.
""" """
self.f = open(fn, "wt") self.f = open(fn, 'wt')
self.last_stream = None self.last_stream = None
self.blocks = [] self.blocks = []
self.cur_evt = 1 self.cur_evt = 1
shutil.copy(mod_dir + "/multiplexed_log.css", os.path.dirname(fn)) shutil.copy(mod_dir + '/multiplexed_log.css', os.path.dirname(fn))
self.f.write("""\ self.f.write('''\
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="multiplexed_log.css"> <link rel="stylesheet" type="text/css" href="multiplexed_log.css">
</head> </head>
<body> <body>
<tt> <tt>
""") ''')
def close(self): def close(self):
"""Close the log file. """Close the log file.
@ -228,17 +228,17 @@ class Logfile(object):
Nothing. Nothing.
""" """
self.f.write("""\ self.f.write('''\
</tt> </tt>
</body> </body>
</html> </html>
""") ''')
self.f.close() self.f.close()
# The set of characters that should be represented as hexadecimal codes in # The set of characters that should be represented as hexadecimal codes in
# the log file. # the log file.
_nonprint = ("%" + "".join(chr(c) for c in range(0, 32) if c not in (9, 10)) + _nonprint = ('%' + ''.join(chr(c) for c in range(0, 32) if c not in (9, 10)) +
"".join(chr(c) for c in range(127, 256))) ''.join(chr(c) for c in range(127, 256)))
def _escape(self, data): def _escape(self, data):
"""Render data format suitable for inclusion in an HTML document. """Render data format suitable for inclusion in an HTML document.
@ -253,8 +253,8 @@ class Logfile(object):
An escaped version of the data. An escaped version of the data.
""" """
data = data.replace(chr(13), "") data = data.replace(chr(13), '')
data = "".join((c in self._nonprint) and ("%%%02x" % ord(c)) or data = ''.join((c in self._nonprint) and ('%%%02x' % ord(c)) or
c for c in data) c for c in data)
data = cgi.escape(data) data = cgi.escape(data)
return data return data
@ -272,11 +272,11 @@ class Logfile(object):
self.cur_evt += 1 self.cur_evt += 1
if not self.last_stream: if not self.last_stream:
return return
self.f.write("</pre>\n") self.f.write('</pre>\n')
self.f.write("<div class=\"stream-trailer\" id=\"" + self.f.write('<div class="stream-trailer" id="' +
self.last_stream.name + "\">End stream: " + self.last_stream.name + '">End stream: ' +
self.last_stream.name + "</div>\n") self.last_stream.name + '</div>\n')
self.f.write("</div>\n") self.f.write('</div>\n')
self.last_stream = None self.last_stream = None
def _note(self, note_type, msg): def _note(self, note_type, msg):
@ -292,9 +292,9 @@ class Logfile(object):
""" """
self._terminate_stream() self._terminate_stream()
self.f.write("<div class=\"" + note_type + "\">\n<pre>") self.f.write('<div class="' + note_type + '">\n<pre>')
self.f.write(self._escape(msg)) self.f.write(self._escape(msg))
self.f.write("\n</pre></div>\n") self.f.write('\n</pre></div>\n')
def start_section(self, marker): def start_section(self, marker):
"""Begin a new nested section in the log file. """Begin a new nested section in the log file.
@ -308,10 +308,10 @@ class Logfile(object):
self._terminate_stream() self._terminate_stream()
self.blocks.append(marker) self.blocks.append(marker)
blk_path = "/".join(self.blocks) blk_path = '/'.join(self.blocks)
self.f.write("<div class=\"section\" id=\"" + blk_path + "\">\n") self.f.write('<div class="section" id="' + blk_path + '">\n')
self.f.write("<div class=\"section-header\" id=\"" + blk_path + self.f.write('<div class="section-header" id="' + blk_path +
"\">Section: " + blk_path + "</div>\n") '">Section: ' + blk_path + '</div>\n')
def end_section(self, marker): def end_section(self, marker):
"""Terminate the current nested section in the log file. """Terminate the current nested section in the log file.
@ -327,13 +327,13 @@ class Logfile(object):
""" """
if (not self.blocks) or (marker != self.blocks[-1]): if (not self.blocks) or (marker != self.blocks[-1]):
raise Exception("Block nesting mismatch: \"%s\" \"%s\"" % raise Exception('Block nesting mismatch: "%s" "%s"' %
(marker, "/".join(self.blocks))) (marker, '/'.join(self.blocks)))
self._terminate_stream() self._terminate_stream()
blk_path = "/".join(self.blocks) blk_path = '/'.join(self.blocks)
self.f.write("<div class=\"section-trailer\" id=\"section-trailer-" + self.f.write('<div class="section-trailer" id="section-trailer-' +
blk_path + "\">End section: " + blk_path + "</div>\n") blk_path + '">End section: ' + blk_path + '</div>\n')
self.f.write("</div>\n") self.f.write('</div>\n')
self.blocks.pop() self.blocks.pop()
def section(self, marker): def section(self, marker):
@ -495,15 +495,15 @@ class Logfile(object):
if stream != self.last_stream: if stream != self.last_stream:
self._terminate_stream() self._terminate_stream()
self.f.write("<div class=\"stream\" id=\"%s\">\n" % stream.name) self.f.write('<div class="stream" id="%s">\n' % stream.name)
self.f.write("<div class=\"stream-header\" id=\"" + stream.name + self.f.write('<div class="stream-header" id="' + stream.name +
"\">Stream: " + stream.name + "</div>\n") '">Stream: ' + stream.name + '</div>\n')
self.f.write("<pre>") self.f.write('<pre>')
if implicit: if implicit:
self.f.write("<span class=\"implicit\">") self.f.write('<span class="implicit">')
self.f.write(self._escape(data)) self.f.write(self._escape(data))
if implicit: if implicit:
self.f.write("</span>") self.f.write('</span>')
self.last_stream = stream self.last_stream = stream
def flush(self): def flush(self):

View File

@ -16,17 +16,17 @@ import sys
sys.argv.pop(0) sys.argv.pop(0)
# argv; py.test test_directory_name user-supplied-arguments # argv; py.test test_directory_name user-supplied-arguments
args = ["py.test", os.path.dirname(__file__) + "/tests"] args = ['py.test', os.path.dirname(__file__) + '/tests']
args.extend(sys.argv) args.extend(sys.argv)
try: try:
os.execvp("py.test", args) os.execvp('py.test', args)
except: except:
# Log full details of any exception for detailed analysis # Log full details of any exception for detailed analysis
import traceback import traceback
traceback.print_exc() traceback.print_exc()
# Hint to the user that they likely simply haven't installed the required # Hint to the user that they likely simply haven't installed the required
# dependencies. # dependencies.
print >>sys.stderr, """ print >>sys.stderr, '''
exec(py.test) failed; perhaps you are missing some dependencies? exec(py.test) failed; perhaps you are missing some dependencies?
See test/py/README.md for the list.""" See test/py/README.md for the list.'''

View File

@ -258,7 +258,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
dfu_write(0, dummy_f.abs_fn) dfu_write(0, dummy_f.abs_fn)
for size in sizes: for size in sizes:
with u_boot_console.log.section("Data size %d" % size): with u_boot_console.log.section('Data size %d' % size):
dfu_write_read_check(size) dfu_write_read_check(size)
# Make the status of each sub-test obvious. If the test didn't # Make the status of each sub-test obvious. If the test didn't
# pass, an exception was thrown so this code isn't executed. # pass, an exception was thrown so this code isn't executed.

View File

@ -112,7 +112,7 @@ def test_net_ping(u_boot_console):
""" """
if not net_set_up: if not net_set_up:
pytest.skip("Network not initialized") pytest.skip('Network not initialized')
output = u_boot_console.run_command('ping $serverip') output = u_boot_console.run_command('ping $serverip')
assert 'is alive' in output assert 'is alive' in output
@ -129,7 +129,7 @@ def test_net_tftpboot(u_boot_console):
""" """
if not net_set_up: if not net_set_up:
pytest.skip("Network not initialized") pytest.skip('Network not initialized')
f = u_boot_console.config.env.get('env__net_tftp_readable_file', None) f = u_boot_console.config.env.get('env__net_tftp_readable_file', None)
if not f: if not f:

View File

@ -31,7 +31,7 @@ def test_shell_semicolon_three(u_boot_console):
def test_shell_run(u_boot_console): def test_shell_run(u_boot_console):
"""Test the "run" shell command.""" """Test the "run" shell command."""
u_boot_console.run_command('setenv foo \"setenv monty 1; setenv python 2\"') u_boot_console.run_command('setenv foo "setenv monty 1; setenv python 2"')
u_boot_console.run_command('run foo') u_boot_console.run_command('run foo')
response = u_boot_console.run_command('echo $monty') response = u_boot_console.run_command('echo $monty')
assert response.strip() == '1' assert response.strip() == '1'