RDFLib/rdflib — Issue #145: Tests break when run under windows
Author: gjhiggins
Created: 2012-02-20 08:33:47+00:00
State: open

Norl...@gmail.com, 2010-12-19T00:27:58.000Z

When doing run_tests.py in rdflib-3.0.0 under windows using python 2.5 I got 3 failures due to URLError
and 2 doctest failures (one for Graph.parse and the other for util.make_date_time).

The URLError problems I traced back to when absolute_location is created on line 152 of parser.py it has a raw windows file path (in my case 'C:\working\rdflib-3.0.0\test\rdfa\w3c_rdfa_testsuite\rdfa-xhtml1-test-manifest.rdf' that gets passed on to URIRef() which then to urljoin() where the drive letter in front of the colon is mistaken for the url type (I don't know if this has been fixed in later python versions - I'm stuck using 2.5 for reasons beyond my control)...

To fix this in parser.py between the lines
---------------------------------------------------------------------
150 if location is not None:
151 base = urljoin("file:", "%s/" % pathname2url(os.getcwd()))
---------------------------------------------------------------------
I inserted the following two lines
---------------------------------------------------------------------
150 if location is not None:
... if os.path.exists(location):
... location = pathname2url(location)
151 base = urljoin("file:", "%s/" % pathname2url(os.getcwd()))
---------------------------------------------------------------------
this also fixed the Graph.parse() doctest failure.

As for parse_date_time the failure occurs in the doctest:
"""
>>> parse_date_time('1970-01-01T00:00:00Z') - 0.0
0.0
"""
due to an underflow in mktime()... while looking at this I tried my own test:
parse_date_time(date_time(0)) which failed for the same reason! but

"""
>> parse_date_time(date_time(36000))
36000
""" passes
and
"""
>> parse_date_time(date_time(35999))
35999
""" fails with the underflow problem also

Im thinking the problem could be anywhere including in the c code for python so I couldn't see the point in tracking this bug any further since to me it seems broken having date time conversions limited by the os epoch while XML Schema dateTime states that integer 0 should be treated as '0001-01-01T00:00:00'

I noticed elsewhere on the issues list someone else has suggested adopting some code from a pre existing iso8601 implementation, here here!

Well hope the above helps out in some way,
thanks for making RDFlib!
-regards Shane Norris

....

The following are the original test errors from my machine

======================================================================
ERROR: Failure: URLError ()
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\python25\lib\site-packages\nose-1.0.0-py2.5.egg\nose\loader.py", line 231, in generate
for test in g():
File "C:\working\rdflib-3.0.0\test\rdfa\run_w3c_rdfa_testsuite.py", line 123,in all_tests
for tc in get_tcs():
File "C:\working\rdflib-3.0.0\test\rdfa\run_w3c_rdfa_testsuite.py", line 54, in get_tcs
graph = Graph().parse(cached_file(manifest_url), publicID=manifest_url)
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 750, in parse
source = create_input_source(source=source, publicID=publicID, location=location, file=file, data=data, format=format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 157, in create_input_source
input_source = URLInputSource(absolute_location, format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 93, in __init__
file = urlopen(req)
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 374, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 397, in _open
'unknown_open', req)
File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1134, in unknown_open
raise URLError('unknown url type: %s' % type)
URLError:
-------------------- >> begin captured logging << --------------------
rdflib: INFO: version: 3.0.0
--------------------- >> end captured logging << ---------------------

======================================================================
ERROR: testNegative (test.test_rdfxml.ParserTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\working\rdflib-3.0.0\test\test_rdfxml.py", line 151, in setUp
manifest.load(cached_file("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf"))
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 761, in load
self.parse(source, publicID, format)
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 750, in parse
source = create_input_source(source=source, publicID=publicID, location=location, file=file, data=data, format=format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 157, in create_input_source
input_source = URLInputSource(absolute_location, format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 93, in __init__
file = urlopen(req)
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 374, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 397, in _open
'unknown_open', req)
File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1134, in unknown_open
raise URLError('unknown url type: %s' % type)
URLError:

======================================================================
ERROR: testPositive (test.test_rdfxml.ParserTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\working\rdflib-3.0.0\test\test_rdfxml.py", line 151, in setUp
manifest.load(cached_file("http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf"))
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 761, in load
self.parse(source, publicID, format)
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 750, in parse
source = create_input_source(source=source, publicID=publicID, location=location, file=file, data=data, format=format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 157, in create_input_source
input_source = URLInputSource(absolute_location, format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 93, in __init__
file = urlopen(req)
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 374, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 397, in _open
'unknown_open', req)
File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1134, in unknown_open
raise URLError('unknown url type: %s' % type)
URLError:

======================================================================
FAIL: Doctest: rdflib.graph.Graph.parse
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python25\lib\doctest.py", line 2112, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for rdflib.graph.Graph.parse
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 693, in parse

----------------------------------------------------------------------
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 736, in rdflib.graph.Graph.
parse
Failed example:
result = g.parse(location=file_name, format="application/rdf+xml")
Exception raised:
Traceback (most recent call last):
File "C:\Python25\lib\doctest.py", line 1212, in __run
compileflags, 1) in test.globs
File "", line 1, in
result = g.parse(location=file_name, format="application/rdf+xml")
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 750, in parse
source = create_input_source(source=source, publicID=publicID, location=location, file=file, data=data, format=format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 157, in create_input_source
input_source = URLInputSource(absolute_location, format)
File "C:\working\rdflib-3.0.0\rdflib\parser.py", line 93, in __init__
file = urlopen(req)
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 374, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 397, in _open
'unknown_open', req)
File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1134, in unknown_open
raise URLError('unknown url type: %s' % type)
URLError:
----------------------------------------------------------------------
File "C:\working\rdflib-3.0.0\rdflib\graph.py", line 737, in rdflib.graph.Graph.parse
Failed example:
len(g)
Expected:
2
Got:
0

======================================================================
FAIL: Doctest: rdflib.util.parse_date_time
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python25\lib\doctest.py", line 2112, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for rdflib.util.parse_date_time
File "C:\working\rdflib-3.0.0\rdflib\util.py", line 98, in parse_date_time

----------------------------------------------------------------------
File "C:\working\rdflib-3.0.0\rdflib\util.py", line 108, in rdflib.util.parse_date_time
Failed example:
parse_date_time('1970-01-01T00:00:01Z') - 1.0
Exception raised:
Traceback (most recent call last):
File "C:\Python25\lib\doctest.py", line 1212, in __run
compileflags, 1) in test.globs
File "", line 1, in
parse_date_time('1970-01-01T00:00:01Z') - 1.0
File "C:\working\rdflib-3.0.0\rdflib\util.py", line 136, in parse_date_time
int(minute), int(second), 0, 0, 0))
OverflowError: mktime argument out of range
----------------------------------------------------------------------
File "C:\working\rdflib-3.0.0\rdflib\util.py", line 111, in rdflib.util.parse_date_time
Failed example:
parse_date_time('1970-01-01T00:00:00Z') - 0.0
Exception raised:
Traceback (most recent call last):
File "C:\Python25\lib\doctest.py", line 1212, in __run
compileflags, 1) in test.globs
File "", line 1, in
parse_date_time('1970-01-01T00:00:00Z') - 0.0
File "C:\working\rdflib-3.0.0\rdflib\util.py", line 136, in parse_date_time
int(minute), int(second), 0, 0, 0))
OverflowError: mktime argument out of range

----------------------------------------------------------------------
Ran 193 tests in 33.313s

FAILED (errors=3, failures=2)