Re: Preventing network access during nose doctest ?
On Mon, 12 May 2014, Olivier Berger wrote:
> Hi.
> I'm trying to fix #739222 where tests fail (-> FTBFS) during execution
> of nose's doctest plugin on something like :
> >>> import rdflib
> >>> g = rdflib.Graph()
> >>> result = g.parse("http://www.w3.org/2000/10/swap/test/meet/white.rdf")
> >>> print("graph has %s statements." % len(g))
> graph has 19 statements.
> I'm puzzled : I'm invoking the tests run with :
> PYBUILD_SYSTEM=custom \
> PYBUILD_TEST_ARGS="{interpreter} run_tests.py" \
> http_proxy= https_proxy= \
> dh_auto_test --buildsystem=pybuild
> where run_tests.py will invoke nose with --with-doctest, but even though
> the HTTP proxy variables being set, they don't seem to be preventing
> urllib2 to try to access the file.
should work AFAICT:
$> python -c 'import rdflib; g = rdflib.Graph(); result = g.parse("http://www.w3.org/2000/10/swap/test/meet/white.rdf"); print("graph has %s statements." % len(g))'
graph has 19 statements.
$> http_proxy=http://127.0.0.1:9/ python -c 'import rdflib; g = rdflib.Graph(); result = g.parse("http://www.w3.org/2000/10/swap/test/meet/white.rdf"); print("graph has %s statements." % len(g))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/rdflib/Graph.py", line 886, in parse
source = self.prepare_input_source(source, publicID)
File "/usr/lib/python2.7/dist-packages/rdflib/Graph.py", line 692, in prepare_input_source
input_source = URLInputSource(location)
File "/usr/lib/python2.7/dist-packages/rdflib/URLInputSource.py", line 21, in __init__
file = urlopen(req)
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>
make sure you exported them in debian/rules:
export http_proxy=http://127.0.0.1:9/
--
Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Research Scientist, Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419
WWW: http://www.linkedin.com/in/yarik
Reply to: