[testlib] Use logilab.common.shellutils.getlogin instead of local hack. oldstable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 01 Dec 2010 17:06:01 +0100
brancholdstable
changeset 6720 43a38c093f6f
parent 6719 3d2b6e6af721
child 6721 a872c391ef86
child 6728 f68bd4c876d1
[testlib] Use logilab.common.shellutils.getlogin instead of local hack.
devtools/testlib.py
--- a/devtools/testlib.py	Wed Dec 01 16:59:57 2010 +0100
+++ b/devtools/testlib.py	Wed Dec 01 17:06:01 2010 +0100
@@ -39,6 +39,7 @@
 from logilab.common.umessage import message_from_string
 from logilab.common.decorators import cached, classproperty, clear_cache
 from logilab.common.deprecation import deprecated
+from logilab.common.shellutils import getlogin
 
 from cubicweb import ValidationError, NoSelectableObject, AuthenticationError
 from cubicweb import cwconfig, devtools, web, server
@@ -222,13 +223,7 @@
         # set default-dest-addrs to a dumb email address to avoid mailbox or
         # mail queue pollution
         config.global_set_option('default-dest-addrs', ['whatever'])
-        try:
-            send_to =  '%s@logilab.fr' % os.getlogin()
-            # AttributeError since getlogin not available under all platforms
-        except (OSError, AttributeError):
-            send_to =  '%s@logilab.fr' % (os.environ.get('USER')
-                                          or os.environ.get('USERNAME')
-                                          or os.environ.get('LOGNAME'))
+        send_to =  '%s@logilab.fr' % getlogin()
         config.global_set_option('sender-addr', send_to)
         config.global_set_option('default-dest-addrs', send_to)
         config.global_set_option('sender-name', 'cubicweb-test')