def test_save_append_extension(self, prog, tmpdir): """Test appending the extension if not present""" filename = str(tmpdir.join("test.txt")) sf.save(filename, prog) with open(filename + '.xbb', "r") as f: res = f.read() assert res == test_prog_not_compiled
def test_save_filename_path_object(self, prog, tmpdir): """Test saving a program to a file path using a path object""" filename = tmpdir.join("test.xbb") sf.save(filename, prog) with open(filename, "r") as f: res = f.read() assert res == test_prog_not_compiled
def test_save_filename_string(self, prog, tmpdir): """Test saving a program to a file path using a string filename""" filename = str(tmpdir.join("test.xbb")) sf.save(filename, prog) with open(filename, "r") as f: res = f.read() assert res == test_prog_not_compiled
def test_save_file_object(self, prog, tmpdir): """Test writing a program to a file object""" filename = tmpdir.join("test.xbb") with open(filename, "w") as f: sf.save(f, prog) with open(filename, "r") as f: res = f.read() assert res == test_prog_not_compiled
def test_load_file_object(self, prog, tmpdir): """Test loading a program via a file object""" filename = tmpdir.join("test.xbb") with open(filename, "w") as f: sf.save(f, prog) with open(filename, "r") as f: res = sf.load(f) # check loaded program is the same as expected self.assert_programs_equal(res, prog)