Hi Cleber, Thanks for the quick follow-up on this. I did a bit more characterization and found that the issue seems to show up only when I'm running in a container (in my case docker). I originally was using 0.45 on master git commit 551619a but also tried upgrading to today's commit 337b333, my observation is that the issue does not occur if I'm running on Linux either VM or native, but occurs when using Docker, which as it happens is the way I am relying on using avocado at the moment.
Here's an example build file that reproduces the error, for reference, to reproduce docker build -f avocado-yaml-oddity.docker -t delete:me . docker run -it --rm delete:me Sample output PARAMS (key=timeout, path=*, default=None) => None START 1-mytest.py:MyTest.test <class 'avocado.plugins.yaml_to_mux.ListOfNodeObjects'> [MuxTreeNode(name='key1'), MuxTreeNode(name='key2')] PASS 1-mytest.py:MyTest.test ----------avocado-yaml-oddity.docker--------- FROM centos:7 RUN yum install -y epel-release RUN yum install -y python-pip RUN pip install avocado-framework RUN pip install -r https://raw.githubusercontent.com/avocado-framework/avocado/master/requirements.txt RUN echo $'#!/bin/env python\n\ import yaml\n\ \n\ from avocado import Test\n\ \n\ \n\ class MyTest(Test):\n\ \n\ def test(self):\n\ with open("some.yaml") as f:\n\ d = yaml.load(f)\n\ print(type(d))\n\ print(d)\n\ \n' > mytest.py RUN echo $'key1:\n\ subkey: subval\n\ key2:\n\ subkey: subval\n\ \n' > some.yaml RUN touch empty.yaml RUN chmod +x mytest.py ENTRYPOINT ["avocado", "run", "--show-job-log", "mytest.py", "--mux-yaml", "empty.yaml"] ------------------------------------------------ FWIW, I tried on both Docker version 1.11.0, build 4dc5990 and version 1.13.1 build 092cba3 Thanks for your help - Vincent On Mon, Feb 13, 2017 at 8:33 AM, Cleber Rosa <cr...@redhat.com> wrote: > > On 02/13/2017 03:33 AM, Vincent Matossian wrote: > > > > I'm seeing an odd behavior on v0.45, when trying to load a yaml file in > > an instrumented test the yaml content gets converted to a list of > > MuxTreeNodes rather than a dictionary. > > > > here's a simple example > > > > mytest.py > > > > #!/bin/env python > > import yaml > > from avocado import Test > > > > class MyTest(Test): > > > > def test(self): > > with open("some.yaml") as f: > > d = yaml.load(f) > > print(type(d)) > > print(d) > > > > > > some.yaml: > > > > key1: > > subkey: subval > > key2: > > subkey: subval > > > > An empty.yaml file > > > > Run: avocado run --show-job-log mytest.py --mux-yaml empty.yaml > > > > Relevant output: > > > > START 1-d.py:MyTest.test > > <class 'avocado.plugins.yaml_to_mux.ListOfNodeObjects'> > > [MuxTreeNode(name='key1'), MuxTreeNode(name='key2')] > > PASS 1-d.py:MyTest.test > > > > If I drop the mux-yaml option then the output looks like what I'd expect > > > > START 1-d.py:MyTest.test > > <type 'dict'> > > {'key2': {'subkey': 'subval'}, 'key1': {'subkey': 'subval'}} > > PASS 1-d.py:MyTest.test > > > > > > On my machine: > > $ avocado --show test run mytest.py | grep -e type -e key1 > <type 'dict'> > {'key2': {'subkey': 'subval'}, 'key1': {'subkey': 'subval'}} > > $ avocado --show test run mytest.py --mux-yaml empty.yaml | grep -e type > -e key1 > <type 'dict'> > {'key2': {'subkey': 'subval'}, 'key1': {'subkey': 'subval'}} > > That is, I can not reproduce it. I'm running avocado from latest master > (337b333e1b58f18f876c993121454f2f6cb599db). Can you share your own > version? > > > --mux-yaml seems to intercept all yaml conversions, this is not > > desirable in my case as I lose the ability to use yaml in my test, my > > apologies for not doing much research on whether this is a known, please > > let me know if I missed the obvious or how I can work around it > > > > If this turns out to be reproducible, it may point at some serious > problems with Avocado: the runner influencing the "yaml" module loaded > in the test. > > I really want to check if this is a current bug. > > > Thanks > > > > Thank you for reporting it. > > > Vincent > > > > -- > Cleber Rosa > [ Sr Software Engineer - Virtualization Team - Red Hat ] > [ Avocado Test Framework - avocado-framework.github.io ] > >