def setup_tests(): directory = os.path.dirname(__file__) xml_idioms_dir = find_dir(directory, "idioms-xml") json_idioms_dir = find_dir(directory, "idioms-json") print("Setting up tests from following directories...") print(xml_idioms_dir) print(json_idioms_dir) for json_filename in sorted(os.listdir(json_idioms_dir)): if json_filename.endswith(".json"): json_path = os.path.join(json_idioms_dir, json_filename) xml_filename = json_filename.replace(".json", ".xml") xml_path = os.path.join(xml_idioms_dir, xml_filename) if os.path.exists(xml_path): xml_file = open(xml_path) io = StringIO(xml_file.read()) loaded_xml = xml.to_etree(io) xml_file.close() MASTER_XML_FILES.append(loaded_xml) JSON_FILENAMES.append(json_filename.split(".")[0]) TESTED_JSON_FILES.append(json_path)
def test_override_default_namespace(): directory = os.path.dirname(__file__) json_idioms_dir = find_dir(directory, "idioms-json") json_path = os.path.join(json_idioms_dir, "cve-in-exploit-target.json") initialize_options() set_option_value("use_namespace", "somenamespace http://somenamespace.com") converted_xml = slide_file(json_path) assert "xmlns:somenamespace=\"http://somenamespace.com\"" in converted_xml assert "id=\"somenamespace:" in converted_xml