[Python-Dev] why is test_socketserver in expected skips?

Guido van Rossum guido@python.org
Thu, 24 Apr 2003 10:18:26 -0400


> test_socketserver seems to be in all the expected skip lists except
> for (oddly enough) os2emx.

Probably because the os2emx port hasn't been updated in a while.

> It correctly bails if the network resource isn't set and the 2.2
> branch version seems to complete for me on my Mac OS X system.  When
> run like:
> 
>     % ./python.exe ../Lib/test/test_socketserver.py
> 
> the 2.3 branch version fails because the network resource isn't enabled:
> 
>     Traceback (most recent call last):
>       File "../Lib/test/test_socketserver.py", line 5, in ?
>         test_support.requires('network')
>       File "/Users/skip/src/python/head/dist/src/Lib/test/test_support.py", line 68, in requires
>         raise ResourceDenied(msg)
>     test.test_support.ResourceDenied: Use of the `network' resource not enabled
>     [5953 refs]
> 
> Seems like a fairly simple change to test_support.requires() would
> correct things:
> 
>     def requires(resource, msg=None):
>         # see if the caller's module is __main__ - if so, treat as if
>         # the resource was set
>         if sys._getframe().f_back.f_globals.get("__name__") == "__main__":
>             return
>         if not is_resource_enabled(resource):
>             if msg is None:
>                 msg = "Use of the `%s' resource not enabled" % resource
>             raise ResourceDenied(msg)
> 
> Someone please shout if the above not-quite-obvious code doesn't look
> correct.

Looks good to me; I've thought of this myself occasionally.  Please
also update the README file for testing to mention this detail!

--Guido van Rossum (home page: http://www.python.org/~guido/)