From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Tue, 22 Oct 2019 23:20:10 -0400 Subject: [U-Boot] [PATCHv2 13/13] test/py: Use raw strings more to avoid deprecation warnings In-Reply-To: <20191023032010.27725-1-trini@konsulko.com> References: <20191018205338.14879-1-trini@konsulko.com> <20191023032010.27725-1-trini@konsulko.com> Message-ID: <20191023032010.27725-14-trini@konsulko.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de We have two further uses of raw string usage in the test/py codebase that are used under CI. The first of which is under the bind test and is a direct update. The second of which is to strip VT100 codes from the match buffer. While switching this to a raw string is also a direct update, the comment it notes that problems were encountered on Ubuntu 14.04 (and whatever Python 2 version that was) that required slight tweaks to the regex. Replace that now that we're saying Python 3.5 is the minimum. Cc: Stephen Warren Signed-off-by: Tom Rini --- Changes in v2: - New patch --- test/py/tests/test_bind.py | 4 ++-- test/py/u_boot_spawn.py | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py index 2d48484c6ac6..20c6050342a9 100644 --- a/test/py/tests/test_bind.py +++ b/test/py/tests/test_bind.py @@ -9,11 +9,11 @@ def in_tree(response, name, uclass, drv, depth, last_child): lines = [x.strip() for x in response.splitlines()] leaf = ' ' * 4 * depth; if not last_child: - leaf = leaf + '\|' + leaf = leaf + r'\|' else: leaf = leaf + '`' leaf = leaf + '-- ' + name - line = (' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$' + line = (r' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$' .format(uclass, drv, leaf)) prog = re.compile(line) for l in lines: diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py index 7fedb18d2790..8fbfd78858e5 100644 --- a/test/py/u_boot_spawn.py +++ b/test/py/u_boot_spawn.py @@ -42,10 +42,7 @@ class Spawn(object): self.after = '' self.timeout = None # http://stackoverflow.com/questions/7857352/python-regex-to-match-vt100-escape-sequences - # Note that re.I doesn't seem to work with this regex (or perhaps the - # version of Python in Ubuntu 14.04), hence the inclusion of a-z inside - # [] instead. - self.re_vt100 = re.compile('(\x1b\[|\x9b)[^@-_a-z]*[@-_a-z]|\x1b[@-_a-z]') + self.re_vt100 = re.compile(r'(\x1b\[|\x9b)[^@-_]*[@-_]|\x1b[@-_]', re.I) (self.pid, self.fd) = pty.fork() if self.pid == 0: -- 2.17.1