code: def setup(self):
          
          testing = settings.get('TESTING')
  
          if testing:
              # Fix nose handler in testing situation.
              config = settings['LOGGERS'].get('', {})
              set_nose_formatter(config)
              #print('testing, set nose formatter: {}'.format(config))
  
          # reset timezone
          os.environ['TZ'] = settings['TIME_ZONE']
          time.tzset()
  
          # determine project name
          if settings._module:
              project = os.path.split(self.root_path)[1]
              if settings['PROJECT']:
                  assert settings['PROJECT'] == project, 'PROJECT specialized in settings (%s) '\
                      'should be the same as project directory name (%s)' % (settings['PROJECT'], project)
              else:
                  settings['PROJECT'] = project
  
          # PROJECT should be importable as a python module
          if settings['PROJECT']:
              # add upper directory path to sys.path if not in
              if settings._module:
                  _abs = os.path.abspath
                  parent_path = os.path.dirname(self.root_path)
                  if not _abs(parent_path) in [_abs(i) for i in sys.path]:
                      sys.path.insert(0, parent_path)
                      app_log.info('Add %s to sys.path' % _abs(parent_path))
              try:
                  __import__(settings['PROJECT'])
                  app_log.debug('import package `%s` success' % settings['PROJECT'])
              except ImportError:
                  raise ImportError('PROJECT could not be imported, may be app.py is outside the project'
                                    'or there is no __init__ in the package.')
  
          self.is_setuped = True
docs: This function will be called both before `run` and testing started.