def test_fromxml_url(): # check internet connection try: url = 'http://raw.githubusercontent.com/petl-developers/petl/master/.pydevproject' urlopen(url) except Exception as e: print('SKIP test_fromxml_url: %s' % e, file=sys.stderr) else: actual = fromxml(url, 'pydev_property', {'name': ( '.', 'name'), 'prop': '.'}) assert nrows(actual) > 0 expect = fromxml('.pydevproject', 'pydev_property', {'name': ( '.', 'name'), 'prop': '.'}) ieq(expect, actual)
def test_fromxml_url(): # check internet connection try: url = 'http://raw.githubusercontent.com/petl-developers/petl/master/petl/test/resources/test.xml' urlopen(url) import pkg_resources filename = pkg_resources.resource_filename('petl', 'test/resources/test.xml') except Exception as e: pytest.skip('SKIP test_fromxml_url: %s' % e) else: actual = fromxml(url, 'pydev_property', {'name': ( '.', 'name'), 'prop': '.'}) assert nrows(actual) > 0 expect = fromxml(filename, 'pydev_property', {'name': ( '.', 'name'), 'prop': '.'}) ieq(expect, actual)
def open(self, mode='r'): if not mode.startswith('r'): raise ArgumentError('source is read-only') f = urlopen(*self.args, **self.kwargs) try: yield f finally: f.close()
def open(self, mode='r'): if self.remote: if not mode.startswith('r'): raise ArgumentError('source is read-only') filehandle = urlopen(self.filename) else: filehandle = self.filename source = bz2.BZ2File(filehandle, mode, **self.kwargs) try: yield source finally: source.close()
</tr> <tr> <td>c</td> <td style='text-align: right'>3</td> </tr> </tbody> </table>""" f = NamedTemporaryFile(delete=False, mode='wt') f.write(data) f.close() actual = fromxml(f.name, './/tr', ('th', 'td')) print(look(actual)) expect = (('foo', 'bar'), ('a', '2'), ('b', '1'), ('c', '3')) ieq(expect, actual) ieq(expect, actual) # verify can iterate twice url = 'http://feeds.bbci.co.uk/news/rss.xml' # check internet connection try: urlopen(url) except Exception as e: print('SKIP test_fromxml_url: %s' % e, file=sys.stderr) else: def test_fromxml_url(): tbl = fromxml(url, './/item', 'title') assert nrows(tbl) > 0
<td style='text-align: right'>3</td> </tr> </tbody> </table>""" f = NamedTemporaryFile(delete=False, mode='wt') f.write(data) f.close() actual = fromxml(f.name, './/tr', ('th', 'td')) print(look(actual)) expect = (('foo', 'bar'), ('a', '2'), ('b', '1'), ('c', '3')) ieq(expect, actual) ieq(expect, actual) # verify can iterate twice url = 'http://feeds.bbci.co.uk/news/rss.xml' # check internet connection try: urlopen(url) except Exception as e: print('SKIP test_fromxml_url: %s' % e, file=sys.stderr) else: def test_fromxml_url(): tbl = fromxml(url, './/item', 'title') assert nrows(tbl) > 0