Exemple #1
0
def load_single_voice_compare_resources():
    ROOT_DIR = __return_root_path() + "/tests/xml"
    return Compare(
        true_filepath=ROOT_DIR + "/compare/ms_F_Lydian_quarter_true.xml",
        test_filepath=ROOT_DIR + "/compare/ms_F_Lydian_quarter_test.xml",
        sorting_algorithm="basic",
    )
Exemple #2
0
def xml_validator(musicxml_filepath,
                  schema_filepath=__return_root_path() +
                  "/tests/xml/musicxml.xsd"):
    """Return if the provided musicxml file is valid against the current musicxml schema.

  :param [musicxml_filepath]: A character string that represents the filepath and filename of the file to open.
  :type [musicxml_filepath]: String

  :param [schema_filepath](optional): A character string that represents the filepath and filename of the schema to use.
  :type [schema_filepath]: String

  :return: Returns a boolean value, either it is a valid MusicXML file or it is not.
  :rtype: Bool
  """
    with open(musicxml_filepath, "rb") as xml_file:
        test = BytesIO(xml_file.read())

    try:
        xml_schema = etree.XMLSchema(etree.parse(schema_filepath))
    except etree.XMLSyntaxError:
        xml_schema = etree.DTD(schema_filepath)

    return xml_schema.validate(etree.parse(test))
Exemple #3
0
import pytest

from mupix.application import xml_validator
from mupix.extra import __return_root_path

ROOT_DIR = __return_root_path() + "/tests/xml"
test_file = ROOT_DIR + "/compare/ms_F_Lydian_quarter_test.xml"


@pytest.mark.slow
def test_xml_validator():
  assert xml_validator(test_file)