[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Preventing network access during nose doctest ?



Nicolas Dandrimont <olasd@debian.org> writes:

> * Olivier Berger <olivier.berger@telecom-sudparis.eu> [2014-05-12 14:36:17 +0200]:
>
>> 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.

Thanks everyone for the hints.

>
> Hi,
>
> Here, you're setting an empty http_proxy variable, which means "don't use a
> proxy". What you really want is to set the proxy to something that errors out,
> e.g. http://127.0.0.1:9/ (the discard port on localhost).
>
> And then, you'll need to disable the tests that need internet access, or modify
> them so that they stop needing it.
>

Indeed I was overly confused : I had previously manually set them to
empty values to workaround the proxy setting made by pybuild internally,
so that the build would effectively access the network... and then I
forgot why I had done that... and of course I hadn't documented that ;)

Sorry about the bothering.

But, then there's still the option of maybe mocking the tests so that we
can proxy locally a copy of the document being fetched... but I'll let
that for another day ;)

Best regards,
-- 
Olivier BERGER 
http://www-public.telecom-sudparis.eu/~berger_o/ - OpenPGP-Id: 2048R/5819D7E8
Ingenieur Recherche - Dept INF
Institut Mines-Telecom, Telecom SudParis, Evry (France)


Reply to: