Esempio n. 1
0
    def test_same_file(self, tmpdir):
        io_dir = tmpdir.mkdir("Game!")
        in_file = io_dir.join("Game!.gdi")
        contents = b"This is the contents of the file"
        in_file.write(contents)

        out_filename = path.join(io_dir, "disc.gdi")
        g = Gdipak()
        g.write_file(in_file.realpath(), out_filename)

        #original file nolonger exists
        assert (not in_file.check())
        with open(out_filename, "br") as f:
            assert (contents == f.read())
Esempio n. 2
0
    def test_missing_directory(self, tmpdir):
        in_dir = tmpdir.mkdir("Game!")
        in_file = in_dir.join("Game!.gdi")
        in_file.write(b"This is the contents of the file")

        out_dir = path.join(tmpdir, "outputdir")
        out_filename = path.join(out_dir, "disc.gdi")
        g = Gdipak()
        g.write_file(in_file.realpath(), out_filename)

        #original file still exists
        assert (in_file.check())
        with open(in_file, "br") as f_in:
            with open(out_filename, "br") as f_out:
                assert (f_in.read() == f_out.read())