[U-Boot] [PATCH v2 3/8] test/py: Import 'configparser' lower case to be python 3.x safe

Michal Simek michal.simek at xilinx.com
Mon Aug 6 10:42:19 UTC 2018


On 14.9.2017 23:34, Paul Burton wrote:
> In python 3.x the configparser module is named with all lower case.
> Import it as such in order to avoid errors when running on python 3.x,
> and fall back to the CamelCase version in order to keep working with
> python 2.x.
> 
> Signed-off-by: Paul Burton <paul.burton at imgtec.com>
> Reviewed-by: Stephen Warren <swarren at nvidia.com>
> 
> ---
> 
> Changes in v2:
> - Import python 2.x ConfigParser as the python 3.x style configparser, rather than the other way around.
> 
>  test/py/conftest.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/test/py/conftest.py b/test/py/conftest.py
> index ced96f1006..bf55bd3d13 100644
> --- a/test/py/conftest.py
> +++ b/test/py/conftest.py
> @@ -19,11 +19,15 @@ import os
>  import os.path
>  import pytest
>  from _pytest.runner import runtestprotocol
> -import ConfigParser
>  import re
>  import StringIO
>  import sys
>  
> +try:
> +    import configparser
> +except:
> +    import ConfigParser as configparser
> +
>  # Globals: The HTML log file, and the connection to the U-Boot console.
>  log = None
>  console = None
> @@ -167,7 +171,7 @@ def pytest_configure(config):
>          with open(dot_config, 'rt') as f:
>              ini_str = '[root]\n' + f.read()
>              ini_sio = StringIO.StringIO(ini_str)
> -            parser = ConfigParser.RawConfigParser()
> +            parser = configparser.RawConfigParser()
>              parser.readfp(ini_sio)
>              ubconfig.buildconfig.update(parser.items('root'))
>  
> 

I have bisect issue with test/py framework on my PC and I end up on this
patch.

Below is the issue I am getting.

And here are my python version.
[u-boot](test)$ python3 --version
Python 3.4.3
[u-boot](test)$ python --version
Python 2.7.6
[u-boot](test)$ which python
/usr/bin/python


Do you know what could be the issue?

Thanks,
Michal


=====================================================================================================
FAILURES
======================================================================================================
_____________________________________________________________________________________________________
test_help
_____________________________________________________________________________________________________

u_boot_console = <u_boot_console_exec_attach.ConsoleExecAttach object at
0x7f1da3e6f290>

    def test_help(u_boot_console):
        """Test that the "help" command can be executed."""

>       u_boot_console.run_command('help')

test/py/tests/test_help.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/py/u_boot_console_base.py:181: in run_command
    self.logstream.write(self.prompt, implicit=True)
test/py/multiplexed_log.py:65: in write
    self.logfile.write(self, data, implicit)
test/py/multiplexed_log.py:688: in write
    self.f.write(self._escape(data))
test/py/multiplexed_log.py:335: in _escape
    c for c in data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

.0 = <iterator object at 0x7f1da3d9bb90>

    data = ''.join((c in self._nonprint) and ('%%%02x' % ord(c)) or
>                  c for c in data)
E   UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position
32: ordinal not in range(128)

test/py/multiplexed_log.py:335: UnicodeDecodeError
===============================================================================================
130 tests deselected
================================================================================================
=====================================================================================
1 failed, 130 deselected in 7.32 seconds
======================================================================================




More information about the U-Boot mailing list