Exemple #1
0
 def test_local_result_creates_necessary_dirs(self, tmp_dir):
     os_independent_template = os.path.join("mydir", "mysubdir",
                                            "{thing}.txt")
     result = LocalResult(dir=tmp_dir, location=os_independent_template)
     new_result = result.write("so-much-data", thing=42)
     assert new_result.location == os.path.join("mydir", "mysubdir",
                                                "42.txt")
     assert new_result.value == "so-much-data"
Exemple #2
0
    def test_local_result_writes_to_dir(self, tmp_dir, res):
        result = LocalResult(dir=tmp_dir, location="test.txt")
        fpath = result.write(res).location
        assert isinstance(fpath, str)
        assert fpath.endswith("test.txt")

        with open(os.path.join(tmp_dir, fpath), "rb") as f:
            val = f.read()
        assert isinstance(val, bytes)
Exemple #3
0
 def test_local_exists_full_path(self, tmp_dir):
     result = LocalResult(dir=tmp_dir, location="{thing}.txt")
     assert result.exists("44.txt") is False
     new_result = result.write("so-much-data", thing=44)
     assert result.exists("44.txt") is True
     assert result.exists(os.path.join(tmp_dir, "44.txt")) is True
Exemple #4
0
 def test_local_result_writes_and_exists(self, tmp_dir):
     result = LocalResult(dir=tmp_dir, location="{thing}.txt")
     assert result.exists("43.txt") is False
     new_result = result.write("so-much-data", thing=43)
     assert result.exists("43.txt") is True
Exemple #5
0
 def test_local_result_writes_and_reads(self, tmp_dir, res):
     result = LocalResult(dir=tmp_dir, location="test.txt")
     final = result.read(result.write(res).location)
     assert final.value == res
Exemple #6
0
 def test_local_result_writes_using_rendered_template_name(self, tmp_dir):
     result = LocalResult(dir=tmp_dir, location="{thing}.txt")
     new_result = result.write("so-much-data", thing=42)
     assert new_result.location.endswith("42.txt")
     assert new_result.value == "so-much-data"