Using temp files and the Internet in regression tests
For the regression tests for the stdlib, is it okay to create temporary files (using tempfile) and connect to the Internet (when the network resource is enabled)? -Brett
For the regression tests for the stdlib, is it okay to create temporary files (using tempfile) and connect to the Internet (when the network resource is enabled)?
Tempfiles: definitely; though if you need a single temporary file, you can use test_support.TESTFN. Connecting to the Internet: only if the network resource is enabled. Then it is up to the tester to make sure that connection to the Internet is possible. --Guido van Rossum (home page: http://www.python.org/~guido/)
[Guido van Rossum]
For the regression tests for the stdlib, is it okay to create temporary files (using tempfile) and connect to the Internet (when the network resource is enabled)?
Tempfiles: definitely; though if you need a single temporary file, you can use test_support.TESTFN.
Perfect. Exactly what I was looking for.
Connecting to the Internet: only if the network resource is enabled. Then it is up to the tester to make sure that connection to the Internet is possible.
Any suggestions on how to go about this? An initial connection to python.org after setting socket.setdefaulttimeout() to something reasonable (like 10 seconds?) and raising test_support.TestSkipped if it times out? -Brett
Connecting to the Internet: only if the network resource is enabled. Then it is up to the tester to make sure that connection to the Internet is possible.
Any suggestions on how to go about this? An initial connection to python.org after setting socket.setdefaulttimeout() to something reasonable (like 10 seconds?) and raising test_support.TestSkipped if it times out?
No, you check whether the 'network' resource name is enabled in test_support. Use test_support.is_resource_enabled('network'). --Guido van Rossum (home page: http://www.python.org/~guido/)
[Guido van Rossum]
Connecting to the Internet: only if the network resource is enabled. Then it is up to the tester to make sure that connection to the Internet is possible.
Any suggestions on how to go about this? An initial connection to python.org after setting socket.setdefaulttimeout() to something reasonable (like 10 seconds?) and raising test_support.TestSkipped if it times out?
No, you check whether the 'network' resource name is enabled in test_support. Use test_support.is_resource_enabled('network').
Actually I knew that. What I was wondering about was how "to make sure that connection to Internet is possible". -Brett
Brett> Actually I knew that. What I was wondering about was how "to Brett> make sure that connection to Internet is possible". If s/he runs ./python Lib/test/regrtest.py -u network you believe the user. ;-) Skip
[Guido van Rossum]
No, you check whether the 'network' resource name is enabled in test_support. Use test_support.is_resource_enabled('network').
Another thought that has come to mind; should we be diligent about creating new objects like good testers? Or should we minimize it since net connections are expensive to make and can hold things up. -Brett
No, you check whether the 'network' resource name is enabled in test_support. Use test_support.is_resource_enabled('network').
Another thought that has come to mind; should we be diligent about creating new objects like good testers? Or should we minimize it since net connections are expensive to make and can hold things up.
Net connections aren't that expensive; you can happily create a new net connection for each individual test. Of course, tests that hold things up should be minimized, but in my experience, tests containing waits (even sleep(0.1)) hold things up much more than opening and closing sockets. --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (3)
-
Brett Cannon
-
Guido van Rossum
-
Skip Montanaro