import pytest
import subprocess
import os
import sys
import StringIO
import struct

prefix = '.'
for i in range(0,3):
    if os.path.exists(os.path.join(prefix, 'pyiso.py')):
        sys.path.insert(0, prefix)
        break
    else:
        prefix = '../' + prefix

import pyiso

from common import *

def test_hybrid_twofiles(tmpdir):
    # First set things up, and generate the ISO with genisoimage.
    outfile = tmpdir.join("twofile-test.iso")
    indir = tmpdir.mkdir("twofile")
    outfp = open(os.path.join(str(tmpdir), "twofile", "foo"), 'wb')
    outfp.write("foo\n")
    outfp.close()
    subprocess.call(["genisoimage", "-v", "-v", "-iso-level", "1", "-no-pad",
                     "-o", str(outfile), str(indir)])

    # Now open up the ISO with pyiso and check some things out.
    iso = pyiso.PyIso()
    iso.open(open(str(outfile), 'rb'))

    barstr = "bar\n"
    iso.add_fp(StringIO.StringIO(barstr), len(barstr), "/BAR")

    check_twofile(iso)

@@ -958,8 +958,720 @@
 le(iso)%0A
+%0Adef test_hybrid_rmfile(tmpdir):%0A    # First set things up, and generate the ISO with genisoimage.%0A    outfile = tmpdir.join(%22twofile-test.iso%22)%0A    indir = tmpdir.mkdir(%22twofile%22)%0A    outfp = open(os.path.join(str(tmpdir), %22twofile%22, %22foo%22), 'wb')%0A    outfp.write(%22foo%5Cn%22)%0A    outfp.close()%0A    outfp = open(os.path.join(str(tmpdir), %22twofile%22, %22bar%22), 'wb')%0A    outfp.write(%22bar%5Cn%22)%0A    outfp.close()%0A    subprocess.call(%5B%22genisoimage%22, %22-v%22, %22-v%22, %22-iso-level%22, %221%22, %22-no-pad%22,%0A                     %22-o%22, str(outfile), str(indir)%5D)%0A%0A    # Now open up the ISO with pyiso and check some things out.%0A    iso = pyiso.PyIso()%0A    iso.open(open(str(outfile), 'rb'))%0A%0A    iso.rm_file(%22/BAR%22)%0A%0A    check_onefile(iso)%0A

Add new hybrid test with removal.