コード例 #1
0
ファイル: test_yaml.py プロジェクト: release-depot/toolchest
def test_good_write(tmp_path):
    expected = {'a': 'apple', 'b': 'banana'}
    output_file = os.path.join(tmp_path, 'generated.yml')
    write(output_file, expected)
    with open(output_file, 'r') as check_fn:
        parsed = parse(check_fn.read())
        assert parsed == expected
コード例 #2
0
ファイル: test_yaml.py プロジェクト: release-depot/toolchest
def test_read_write_roundtrip(datadir, tmp_path):
    output_file = os.path.join(tmp_path, 'generated.yml')
    input_file = os.path.join(datadir, 'sample.yml')
    with open(input_file, 'r') as input_fh:
        output_data = parse(input_fh.read())
        write(output_file, output_data)
        # If an exception is raised the files contain a diff and the test
        # will fail. We want to make sure we can write out in the same format
        # that we read in.
        subprocess.check_call(['diff', input_file, output_file])
コード例 #3
0
ファイル: manager.py プロジェクト: release-depot/atkinson
    def _parse(self, filename):
        """
        Method to parse the config data

        :param filename: The fully qualified path to load and parse
        """
        with open(filename, 'r') as file_handle:
            data = yaml.parse(file_handle.read())
            self.config_data = _update(self._config_data, data)
            self._config_files.append(filename)
コード例 #4
0
def _fetch_yaml(url):
    """
    Fetch remote data and process the text as yaml.

    :param url: The URL to fetch the data from
    :return: Parsed yaml data in the form of a dictionary
    """
    ret_data = None
    raw_data = _raw_fetch(url)
    if raw_data is not None:
        ret_data = yaml.parse(raw_data)

    return ret_data
コード例 #5
0
ファイル: test_yaml.py プロジェクト: release-depot/toolchest
def test_file_read(datadir):
    file_to_load = os.path.join(datadir, 'sample.yml')
    expected = {'a': 1, 'b': 2, 'c': [7, 8, 9]}
    file_handle = open(file_to_load, 'r')
    actual = parse(file_handle.read())
    assert actual == expected
コード例 #6
0
ファイル: test_yaml.py プロジェクト: release-depot/toolchest
def test_bad_string():
    expected = {}
    input_str = ':'
    actual = parse(input_str)
    assert actual == expected
コード例 #7
0
ファイル: test_yaml.py プロジェクト: release-depot/toolchest
def test_simple_string():
    expected = {'a': 1}
    input_str = '---\na: 1'
    actual = parse(input_str)
    assert actual == expected