def register_from_text(cls, text): from zops.anatomy.yaml import yaml_load from zops.anatomy.text import dedent text = dedent(text) contents = yaml_load(text) return cls.register_from_contents(contents)
def test_duplicate_keys(): from zops.anatomy.yaml import yaml_load from zops.anatomy.text import dedent with pytest.raises(DuplicateKeyError): yaml_load( dedent(""" root: alpha: 1 alpha: 2 """))
def assert_file_contents(filename, expected): from zops.anatomy.text import dedent from datadiff.tools import assert_equal import os assert os.path.isfile(filename), "{}: File does not exists.".format( filename) obtained = open(filename, 'r').read() expected = dedent(expected) assert_equal(obtained, expected)
def test_ordereddict(): from zops.anatomy.yaml import yaml_load from zops.anatomy.text import dedent contents = yaml_load( dedent(""" root: alpha: 1 bravo: 2 charlie: 3 echo: 4 foxtrot: 5 golf: 6 hotel: 7 """)) assert isinstance(contents, OrderedDict) assert isinstance(contents['root'], OrderedDict)
def __init__(self, filename, contents, executable=False): self.__filename = filename self.__contents = dedent(contents) self.__executable = executable
def _to_contents(seed): from zops.anatomy.yaml import yaml_load from zops.anatomy.text import dedent return yaml_load(dedent(seed))