def test_macro_macroset_append_object(self, tmpdir): m = GetAsset('macro/MVMacro1.xml') assert m is not None o = GetAsset('MVMacroSet.mtmacset') assert o is not None o.append(m) assert o is not None # see if o now has two copies of m assert len(o.root.findall('./' + tagset.macro.tag)) == 3
def test_properties_append_string(self, tmpdir): newname = random_string() newfilename = newname + '.' + tagset.properties.ext m = GetAsset('MVProps/content.xml') assert m is not None m.append('MVProps2', 'tokenTypeMap', 'entry[string="Second"]') m.assemble(save_name=newname) assert os.path.exists(newfilename) n = GetAsset(newfilename) assert n.xml.find('tokenTypeMap/entry[string="Second"]') is not None
def setup_method(self, tmpdir): mvp = 'test/data/MinViable' for zf in glob(mvp + '/*.zip'): with zipfile.ZipFile(zf, 'r') as zip_ref: zip_ref.extractall(tmpdir) test_start_dir = os.getcwd() os.chdir(tmpdir) # Create a sample MVMacroSet.mtmacset for # the tests to use m = GetAsset('macro/MVMacro1.xml') n = GetAsset('macro/MVMacro2.xml') assert m is not None assert m.is_macro assert n is not None assert n.is_macro m.append(n) m.assemble(save_name='MVMacroSet') try: yield finally: os.chdir(test_start_dir)
def setup_method(self, tmpdir): mvp = 'test/data/MinViable' mvzips = ['MVMacro1.zip', 'MVMacro2.zip', 'MVProps.zip', 'MVToken.zip'] for zf in [os.path.join(mvp, z) for z in mvzips]: with zipfile.ZipFile(zf, 'r') as zip_ref: zip_ref.extractall(tmpdir) test_start_dir = os.getcwd() os.chdir(tmpdir) # Create a sample MVMacroSet.mtmacset for # the tests to use m = GetAsset('macro/MVMacro1.xml') n = GetAsset('macro/MVMacro2.xml') assert m is not None assert m.is_macro assert n is not None assert n.is_macro m.append(n) m.assemble(save_name='MVMacroSet') try: yield finally: os.chdir(test_start_dir)
def test_macro_append_macro_object(self, tmpdir): newname = random_string() newfilename = newname + '.' + tagset.macroset.ext m = GetAsset('macro/MVMacro1.xml') n = GetAsset('macro/MVMacro2.xml') assert m is not None assert m.is_macro assert n is not None assert n.is_macro m.append(n) # This is a weird one, it doesn't actually change # the type of object, just the contents, but since # they share the same base object, it works. assert m.tag == tagset.macroset.tag assert m.is_macroset m.assemble(save_name=newname) assert os.path.exists(newfilename) o = GetAsset(newfilename) assert o is not None assert o.is_macroset assert o.tag == tagset.macroset.tag assert type(o) == MTMacroSet for tag in [x.tag for x in o.root.iterchildren()]: assert tag == tagset.macro.tag
def test_properties_append_invalid_string(self, tmpdir): fakename = random_string() m = GetAsset('MVProps/content.xml') assert m is not None with pytest.raises(FileNotFoundError): m.append(fakename, 'tokenTypeMap', 'entry[string="Second"]')