示例#1
0
def write_table(file: str, headers: List[str], content: Dict[str, Dict[str, str]]):
    with safe_open(file, 'w+', newline='') as result_file:
        w = csv.DictWriter(result_file, fieldnames=headers)
        w.writeheader()
        for row_key in sorted(content):
            print(row_key, end='', file=result_file)
            w.writerow({column_key: content[row_key].get(column_key, '') for column_key in headers[1:]})
示例#2
0
    def test_reads_project_file(self):
        test_dict = {"name": "Project Name"}
        with safe_open(self.uut._project_file, 'w+') as stream:
            yaml.dump(test_dict, stream)

        assert_equals(test_dict, self.uut._yaml)
示例#3
0
 def test_open_file_creates_directories_implicitly(self):
     safe_open(self.test_file, 'w+').close()
     assert isfile(self.test_file)
示例#4
0
    def test_reads_version_file(self):
        test_dict = {"revision": "42"}
        with safe_open(self.uut._version_file, 'w+') as stream:
            yaml.dump(test_dict, stream)

        assert_equals(test_dict, self.uut._yaml)