Re: [Tutor] Help error 504

2015-08-26 Thread Peter Otten
Danny Yoo wrote: > Unit tests that depend on external dependencies can be "flaky": they > might fail for reasons that you don't anticipate. I'd recommend not > depending on an external web site like this: it puts load on someone > else, which they might not appreciate. If you have a well-defined

Re: [Tutor] Help error 504

2015-08-25 Thread Danny Yoo
Unit tests that depend on external dependencies can be "flaky": they might fail for reasons that you don't anticipate. I'd recommend not depending on an external web site like this: it puts load on someone else, which they might not appreciate. Making the test not depend on the network is not ba

Re: [Tutor] Help error 504

2015-08-25 Thread Laura Creighton
Thanks Timo! I never heard of this one before! Laura ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help error 504

2015-08-25 Thread Peter Otten
Timo wrote: > Op 25-08-15 om 02:08 schreef Gonzalo V: >> how can simulate or emulate an error 504? > I think using a site like http://httpbin.org/ is a bit easier than mock > or your own server. > Just change your request url to: > http://httpbin.org/status/504 Yes, that's nice! Plus, it's

Re: [Tutor] Help error 504

2015-08-25 Thread Timo
Op 25-08-15 om 02:08 schreef Gonzalo V: how can simulate or emulate an error 504? I think using a site like http://httpbin.org/ is a bit easier than mock or your own server. Just change your request url to: http://httpbin.org/status/504 Timo i am new in python and its very intuitive! but

Re: [Tutor] Help error 504

2015-08-25 Thread Peter Otten
Gonzalo V wrote: > i am new in python and its very intuitive! but i am in problems with that > code. As Danny already explained an exception can only be caught if the function is inside a try ... except ...: try: req = urllib.request.urlopen(...) except urllib.error.HTTPError as e: ...

Re: [Tutor] Help error 504

2015-08-25 Thread Laura Creighton
I use mock for this. See this blog post which explains it much clearer than I could. http://engineroom.trackmaven.com/blog/real-life-mocking/ Laura ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.pyt

Re: [Tutor] Help error 504

2015-08-25 Thread Danny Yoo
In your program, you have a try/ except block, but it does not surround the line: req=urllib.request.urlopen(''+line) You probably should modify the extent of the exception handling to include that part. If you are seeing a 504, I expect it to come at this point. __

[Tutor] Help error 504

2015-08-25 Thread Gonzalo V
how can simulate or emulate an error 504? i am new in python and its very intuitive! but i am in problems with that code. i wrote this code and it cant handle 504 error: import urllib.request import urllib.error from bs4 import BeautifulSoup import re, csv from FuncionCsv import LlenarCsv fhand