devtools/testlib.py
brancholdstable
changeset 6720 43a38c093f6f
parent 6589 47cd31fd206b
child 6721 a872c391ef86
equal deleted inserted replaced
6719:3d2b6e6af721 6720:43a38c093f6f
    37 from logilab.common.pytest import nocoverage, pause_tracing, resume_tracing
    37 from logilab.common.pytest import nocoverage, pause_tracing, resume_tracing
    38 from logilab.common.debugger import Debugger
    38 from logilab.common.debugger import Debugger
    39 from logilab.common.umessage import message_from_string
    39 from logilab.common.umessage import message_from_string
    40 from logilab.common.decorators import cached, classproperty, clear_cache
    40 from logilab.common.decorators import cached, classproperty, clear_cache
    41 from logilab.common.deprecation import deprecated
    41 from logilab.common.deprecation import deprecated
       
    42 from logilab.common.shellutils import getlogin
    42 
    43 
    43 from cubicweb import ValidationError, NoSelectableObject, AuthenticationError
    44 from cubicweb import ValidationError, NoSelectableObject, AuthenticationError
    44 from cubicweb import cwconfig, devtools, web, server
    45 from cubicweb import cwconfig, devtools, web, server
    45 from cubicweb.dbapi import ProgrammingError, DBAPISession, repo_connect
    46 from cubicweb.dbapi import ProgrammingError, DBAPISession, repo_connect
    46 from cubicweb.sobjects import notification
    47 from cubicweb.sobjects import notification
   220         #                         '/tmp/test_rql_log.' + `os.getpid()`)
   221         #                         '/tmp/test_rql_log.' + `os.getpid()`)
   221         config.global_set_option('log-file', None)
   222         config.global_set_option('log-file', None)
   222         # set default-dest-addrs to a dumb email address to avoid mailbox or
   223         # set default-dest-addrs to a dumb email address to avoid mailbox or
   223         # mail queue pollution
   224         # mail queue pollution
   224         config.global_set_option('default-dest-addrs', ['whatever'])
   225         config.global_set_option('default-dest-addrs', ['whatever'])
   225         try:
   226         send_to =  '%s@logilab.fr' % getlogin()
   226             send_to =  '%s@logilab.fr' % os.getlogin()
       
   227             # AttributeError since getlogin not available under all platforms
       
   228         except (OSError, AttributeError):
       
   229             send_to =  '%s@logilab.fr' % (os.environ.get('USER')
       
   230                                           or os.environ.get('USERNAME')
       
   231                                           or os.environ.get('LOGNAME'))
       
   232         config.global_set_option('sender-addr', send_to)
   227         config.global_set_option('sender-addr', send_to)
   233         config.global_set_option('default-dest-addrs', send_to)
   228         config.global_set_option('default-dest-addrs', send_to)
   234         config.global_set_option('sender-name', 'cubicweb-test')
   229         config.global_set_option('sender-name', 'cubicweb-test')
   235         config.global_set_option('sender-addr', 'cubicweb-test@logilab.fr')
   230         config.global_set_option('sender-addr', 'cubicweb-test@logilab.fr')
   236         # default_base_url on config class isn't enough for TestServerConfiguration
   231         # default_base_url on config class isn't enough for TestServerConfiguration