import os import pytest from lxml import etree from obsapi import FileInfo from . import test_dir with open(os.path.join(test_dir, 'binary_fileinfo.xml'), 'rb') as f: xml_as_bytes = f.read() with open(os.path.join(test_dir, 'binary_fileinfo.xml'), 'r') as f: xml_as_str = f.read() @pytest.mark.parametrize('xml', (xml_as_bytes, xml_as_str)) def test_fileinfo(xml): finfo = FileInfo(xml) root = etree.fromstring(xml) assert finfo.name == root.find('name').text assert finfo.version == root.find('version').text assert finfo.release == root.find('release').text assert finfo.arch == root.find('arch').text assert finfo.summary == root.find('summary').text assert finfo.description == root.find('description').text assert len(finfo.requires) == len(root.findall('requires'))