def test_read(self): """Test the reader's ability to read.""" # read a local file foo = os.path.join(os.getcwd(), *TESTDATAPATH, 'authors.ttl') r = TTLReader(foo) assert_equals(r.read(), 670) assert_is_not_none(r.graph) del(r) # try to read a non-existent local file foo = os.path.join(os.getcwd(), *TESTDATAPATH, 'bogus.ttl') r = TTLReader(foo) try: r.read() except FileNotFoundError as inst: assert_equals( inst.__str__().split(':')[0], '[Errno 2] No such file or directory' ) # read a file on the web foo = PLEIADES_URLS['place-types']['turtle'] r = TTLReader(foo) assert_is_not_none(r.read()) del(r) # try to read a bogus file on the web foo = 'http://atlantides.org/bogus.ttl' r = TTLReader(foo) try: r.read() except HTTPError as inst: assert_equals( inst.__str__(), 'HTTP Error 404: Not Found' ) del(r) # try to read a bogus file from a bogus site on the web foo = 'http://nowhere.org/bogus.ttl' r = TTLReader(foo) try: r.read() except URLError as inst: assert_equals( inst.__str__(), ( '<urlopen error [Errno 8] nodename nor servname ' 'provided, or not known>' ) ) del(r)
def __init__(self, src: str=PLEIADES_URLS['authors']['turtle']): Feeder.__init__(self, src) TTLReader.__init__(self)