OK, it's what I was fearing of but never dared to try. I'm sorry it's my fault, I was aware that this might happen but I simply neglected this because I inspired by the official example and ignore the fact that it modifies the yaml.Loader directly. Anyway I have an ugly fix and the clean PR is coming after some testing.

```
diff --git a/avocado/plugins/yaml_to_mux.py b/avocado/plugins/yaml_to_mux.py
index c5ed443..34cf482 100644
--- a/avocado/plugins/yaml_to_mux.py
+++ b/avocado/plugins/yaml_to_mux.py
@@ -34,6 +34,10 @@ else:
         from yaml import Loader


+class MyLoader(Loader):
+    pass
+
+
 # Mapping for yaml flags
 YAML_INCLUDE = 100
 YAML_USING = 101
@@ -143,16 +147,16 @@ def _create_from_yaml(path, cls_node=mux.MuxTreeNode):
         objects.append((mux.Control(YAML_MUX), None))
         return objects

-    Loader.add_constructor(u'!include',
+    MyLoader.add_constructor(u'!include',
                            lambda loader, node: mux.Control(YAML_INCLUDE))
-    Loader.add_constructor(u'!using',
+    MyLoader.add_constructor(u'!using',
                            lambda loader, node: mux.Control(YAML_USING))
-    Loader.add_constructor(u'!remove_node',
+    MyLoader.add_constructor(u'!remove_node',
lambda loader, node: mux.Control(YAML_REMOVE_NODE))
-    Loader.add_constructor(u'!remove_value',
+    MyLoader.add_constructor(u'!remove_value',
lambda loader, node: mux.Control(YAML_REMOVE_VALUE))
-    Loader.add_constructor(u'!mux', mux_loader)
-    Loader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
+    MyLoader.add_constructor(u'!mux', mux_loader)
+ MyLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
                            mapping_to_tree_loader)

     # Parse file name ([$using:]$path)
@@ -169,7 +173,7 @@ def _create_from_yaml(path, cls_node=mux.MuxTreeNode):

     # Load the tree
     with open(path) as stream:
-        loaded_tree = yaml.load(stream, Loader)
+        loaded_tree = yaml.load(stream, MyLoader)
         if loaded_tree is None:
             return
         loaded_tree = tree_node_from_values('', loaded_tree)
```

Dne 15.2.2017 v 14:18 Lukáš Doktor napsal(a):
Hello Vincent,

I'm able to reproduce that with your docker file so I'll do my best to
find the root cause and fix it.

Regards,
Lukáš

Dne 13.2.2017 v 19:44 Vincent Matossian napsal(a):
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"]


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to