def assertDiff(self, filename, version=2): orig = os.path.join(os.path.expanduser("~"), filename) saved = orig.replace(".mscx", "_saved.mscx") tmp = helper.get_tmpfile_path(filename, version=version) shutil.copy2(tmp, orig) tree = MscoreXmlTree(tmp) tree.save(new_name=saved) self.assertTrue(filecmp.cmp(orig, saved)) os.remove(orig) os.remove(saved)
def _assert_set(self, filename, version=2): tmp = helper.get_tmpfile_path(filename, version) tree = MscoreXmlTree(tmp) vbox = Vbox(tree.xml_root) vbox.Title = "lol" vbox.composer = "lol" tree.save() tree = MscoreXmlTree(tmp) vbox = Vbox(tree.xml_root) self.assertEqual(vbox.title, "lol") self.assertEqual(vbox.Composer, "lol") xml_string = helper.read_file(tmp) self.assertTrue("<text>lol</text>" in xml_string)
def test_method_clean(self): tmp = helper.get_tmpfile_path("clean.mscx", version=3) tree = MscoreXmlTree(tmp) tree.clean() tree.save() tree = MscoreXmlTree(tmp) xml_tree = tree.xml_tree self.assertEqual(xml_tree.xpath("/museScore/Score/Style"), []) self.assertEqual(xml_tree.xpath("//LayoutBreak"), []) self.assertEqual(xml_tree.xpath("//StemDirection"), []) self.assertEqual(xml_tree.xpath("//font"), []) self.assertEqual(xml_tree.xpath("//b"), []) self.assertEqual(xml_tree.xpath("//i"), []) self.assertEqual(xml_tree.xpath("//pos"), []) self.assertEqual(xml_tree.xpath("//offset"), [])
def test_method_clean(self): tmp = helper.get_tmpfile_path('clean.mscx', version=3) tree = MscoreXmlTree(tmp) tree.clean() tree.save() tree = MscoreXmlTree(tmp) xml_tree = tree.xml_tree self.assertEqual(xml_tree.xpath('/museScore/Score/Style'), []) self.assertEqual(xml_tree.xpath('//LayoutBreak'), []) self.assertEqual(xml_tree.xpath('//StemDirection'), []) self.assertEqual(xml_tree.xpath('//font'), []) self.assertEqual(xml_tree.xpath('//b'), []) self.assertEqual(xml_tree.xpath('//i'), []) self.assertEqual(xml_tree.xpath('//pos'), []) self.assertEqual(xml_tree.xpath('//offset'), [])
def test_method_save_new_name(self): tmp = helper.get_tmpfile_path("simple.mscx") tree = MscoreXmlTree(tmp) tree.save(new_name=tmp) result = helper.read_file(tmp) self.assertTrue('<metaTag name="arranger"></metaTag>' in result)