Exemple #1
0
    def test_write_ordereddict(self):
        d = OrderedDict([("the", "a"), ("order", "z"), ("is", "b"), ("important", "y")])
        yaml.dump(d, open(os.path.join(self.dir_path, "output.yaml"), "w"))

        loaded = yaml.load(open(os.path.join(self.dir_path, "output.yaml"), "r"))
        assert type(loaded) == OrderedDict
        assert loaded.keys() == ["the", "order", "is", "important"]
Exemple #2
0
    def test_write_string(self):
        d = OrderedDict([("the", "a"), ("order", "z"), ("is", "b"), ("important", "y")])
        string = yaml.dump(d)

        loaded = yaml.load(string)
        assert type(loaded) == OrderedDict
        assert loaded.keys() == ["the", "order", "is", "important"]
Exemple #3
0
    def test_write_long_str(self):
        d = {"key": """This is a very long string
        that should be multiline in the yaml!


        minimum 6 lines!"""}
        string = yaml.dump(d)
        assert len(string.splitlines()) == 6
Exemple #4
0
    def test_write_long_str_obj(self):
        class strange_object(object):
            def __str__(self):
                return """This is a very long string
                    that should be multiline in the yaml!


                    minimum 6 lines!"""

        string = yaml.dump({"key": strange_object()})
        assert len(string.splitlines()) == 6
Exemple #5
0
def update_output_yaml(test_dir):
    """ Put the internal json as yaml to ensure readability """
    f = open(os.path.join(test_dir, "feedback.yaml"), "w")
    if os.path.exists(os.path.join(test_dir, 'output', "__feedback.json")):
        yaml.dump(json.load(open(os.path.join(test_dir, 'output', "__feedback.json"), 'r')), stream=f)