Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

How to test urllib|urllib2-using code?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


no.email at please

Nov 4, 2009, 5:33 AM

Post #1 of 6 (379 views)
Permalink
How to test urllib|urllib2-using code?

I want to write some tests for code that uses both urllib and
urllib2. I would like to be able to run these tests locally. Are
there modules to facilitate the writing of such tests (e.g. for
setting up a mock web server locally, etc.)?

BTW, in the Perl world, one very easy way to learn how to write
tests for stuff is to study the test suites that come with every
module distribution, and which are usually readily recognizable as
a bunch of files of the form t/*.t. (E.g. I'm sure I could find
some good answers to my question above if I could look at the test
suites for urllib and urllib2, but I can't find them anywhere. In
fact, I don't even know what exactly I should be looking for.)
Where can I find the equivalent for Python distributions?

Thanks!

kynn
--
http://mail.python.org/mailman/listinfo/python-list


lutz.horn at fastmail

Nov 4, 2009, 6:06 AM

Post #2 of 6 (372 views)
Permalink
Re: How to test urllib|urllib2-using code? [In reply to]

Hi,

kj wrote:
> I want to write some tests for code that uses both urllib and
> urllib2.

Take a look at the discussion under the title "How can one mock/stub
python module like urllib" at stackoverflow:

http://stackoverflow.com/questions/295438/how-can-one-mock-stub-python-module-like-urllib

Lutz
--
http://mail.python.org/mailman/listinfo/python-list


steven at REMOVE

Nov 4, 2009, 3:47 PM

Post #3 of 6 (360 views)
Permalink
Re: How to test urllib|urllib2-using code? [In reply to]

On Wed, 04 Nov 2009 15:06:45 +0100, Lutz Horn wrote:

> Hi,
>
> kj wrote:
>> I want to write some tests for code that uses both urllib and urllib2.
>
> Take a look at the discussion under the title "How can one mock/stub
> python module like urllib" at stackoverflow:
>
> http://stackoverflow.com/questions/295438/how-can-one-mock-stub-python-
module-like-urllib

Oh noes!!! Ur fragmenting teh python communities!!!!1!!! DO NOT WANT!!!


*grin*

(And for those who don't know what on earth I'm referring to, see the
thread "Pyfora, a place for python".)



--
Steven
--
http://mail.python.org/mailman/listinfo/python-list


gagsl-py2 at yahoo

Nov 5, 2009, 12:16 AM

Post #4 of 6 (358 views)
Permalink
Re: How to test urllib|urllib2-using code? [In reply to]

En Wed, 04 Nov 2009 10:33:53 -0300, kj <no.email [at] please> escribió:

> I'm sure I could find
> some good answers to my question above if I could look at the test
> suites for urllib and urllib2, but I can't find them anywhere. In
> fact, I don't even know what exactly I should be looking for.)
> Where can I find the equivalent for Python distributions?

Most of the Python test suite is in the "test" subdirectory below the
standard library; on Windows that's c:\PythonNN\Lib\test, on Linux
/usr/lib/pythonN.N/test or /usr/local/...

> dir /s/b test_url*.py
D:\apps\Python26\Lib\test\test_urllib.py
D:\apps\Python26\Lib\test\test_urllib2.py
D:\apps\Python26\Lib\test\test_urllib2net.py
D:\apps\Python26\Lib\test\test_urllib2_localnet.py
D:\apps\Python26\Lib\test\test_urllibnet.py
D:\apps\Python26\Lib\test\test_urlparse.py

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


no.email at please

Nov 5, 2009, 7:15 AM

Post #5 of 6 (346 views)
Permalink
Re: How to test urllib|urllib2-using code? [In reply to]

In <hcs1r2$vgp$1 [at] online> Lutz Horn <lutz.horn [at] fastmail> writes:

>Hi,

>kj wrote:
>> I want to write some tests for code that uses both urllib and
>> urllib2.

>Take a look at the discussion under the title "How can one mock/stub
>python module like urllib" at stackoverflow:

>http://stackoverflow.com/questions/295438/how-can-one-mock-stub-python-module-like-urllib

Thanks, that helped.

kynn
--
http://mail.python.org/mailman/listinfo/python-list


no.email at please

Nov 5, 2009, 7:16 AM

Post #6 of 6 (345 views)
Permalink
Re: How to test urllib|urllib2-using code? [In reply to]

In <mailman.2633.1257408984.2807.python-list [at] python> "Gabriel Genellina" <gagsl-py2 [at] yahoo> writes:

>En Wed, 04 Nov 2009 10:33:53 -0300, kj <no.email [at] please> escribió:

>> I'm sure I could find
>> some good answers to my question above if I could look at the test
>> suites for urllib and urllib2, but I can't find them anywhere. In
>> fact, I don't even know what exactly I should be looking for.)
>> Where can I find the equivalent for Python distributions?

>Most of the Python test suite is in the "test" subdirectory below the
>standard library; on Windows that's c:\PythonNN\Lib\test, on Linux
>/usr/lib/pythonN.N/test or /usr/local/...

>> dir /s/b test_url*.py
>D:\apps\Python26\Lib\test\test_urllib.py
>D:\apps\Python26\Lib\test\test_urllib2.py
>D:\apps\Python26\Lib\test\test_urllib2net.py
>D:\apps\Python26\Lib\test\test_urllib2_localnet.py
>D:\apps\Python26\Lib\test\test_urllibnet.py
>D:\apps\Python26\Lib\test\test_urlparse.py


Muy agradecido,

kynn

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.