def test_load_from_path_missing_file(): with pytest.raises(IOError): load_from_path('akk') with pytest.raises(IOError): load_from_path('tests.akk') with pytest.raises(IOError): load_from_path('test/akk')
def test_load_from_os_path(): assert load_from_path( 'tests/load_from_path.data' ) == 'one\ntwo\nthree\n'
def test_load_from_path_file(): assert load_from_path( 'tests.load_from_path.data', 'data' ) == 'one\ntwo\nthree\n'
def test_load_from_path_list(): assert load_from_path(['one', 'two']) == ['one', 'two']
def test_load_from_path_string(string_file): assert load_from_path(string_file) == 'one\ntwo'
('<simple><a></a><b></b></simple>', 2, { 'a': {}, 'b': {} }), ('<simple><a></a><b>doh</b></simple>', 2, { 'a': {}, 'b': 'doh' }), ]) def test_simple(value, length, content): d = from_xml(value) c = d['simple'] assert len(c) == length assert c == content @pytest.mark.parametrize('data', [ (load_from_path('tests.from_xml.data', 'data')), (open(normalize_path('tests.from_xml.data', 'data'))), ]) def test_parts(data): d = from_xml(data) d = d['PARTS'] assert 'TITLE' in d assert 'PART' in d p = d['PART'] assert len(p) == 4 item = [part for part in p if part['ITEM'] == 'Motherboard'][0] assert item['MANUFACTURER'] == 'ASUS'