Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to test urllib|urllib2-using code?

Reply
Thread Tools

How to test urllib|urllib2-using code?

 
 
kj
Guest
Posts: n/a
 
      11-04-2009



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
 
Reply With Quote
 
 
 
 
Lutz Horn
Guest
Posts: n/a
 
      11-04-2009
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/2...le-like-urllib

Lutz
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      11-04-2009
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/2...k-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
 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      11-05-2009
En Wed, 04 Nov 2009 10:33:53 -0300, kj <(E-Mail Removed)> 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

 
Reply With Quote
 
kj
Guest
Posts: n/a
 
      11-05-2009
In <hcs1r2$vgp$(E-Mail Removed)> Lutz Horn <(E-Mail Removed)> 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/2...le-like-urllib


Thanks, that helped.

kynn
 
Reply With Quote
 
kj
Guest
Posts: n/a
 
      11-05-2009
In <(E-Mail Removed)> "Gabriel Genellina" <(E-Mail Removed)> writes:

>En Wed, 04 Nov 2009 10:33:53 -0300, kj <(E-Mail Removed)> 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.p y
>D:\apps\Python26\Lib\test\test_urllibnet.py
>D:\apps\Python26\Lib\test\test_urlparse.py



Muy agradecido,

kynn
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
TEST TEST Test...Blah Blah Blah generalbatguano@pacbell.net Computer Support 2 09-15-2006 03:47 AM
TEST TEST Test...Blah Blah Blah Generalbatguano@pacbell.net Computer Support 6 09-13-2006 01:53 AM
TEST TEST TEST Gazwad Computer Support 2 09-05-2003 07:32 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments