Edgewall Software

Ticket #8388: t8388-testenv_subclass-r8265-011.diff

File t8388-testenv_subclass-r8265-011.diff, 3.0 KB (added by osimons, 3 years ago)

Easier reuse of functional test infrastructure.

  • trac/tests/functional/testenv.py

    diff --git a/trac/tests/functional/testenv.py b/trac/tests/functional/testenv.py
    a b  
    5353        self.htpasswd = os.path.join(self.dirname, "htpasswd") 
    5454        self.port = port 
    5555        self.pid = None 
     56        self.init() 
    5657        self.destroy() 
    5758        self.create() 
    5859        locale.setlocale(locale.LC_ALL, '') 
    5960 
     61    trac_src = '.' 
    6062    dburi = property(lambda x: get_dburi()) 
    6163 
    6264    def destroy(self): 
     
    7173 
    7274    repotype = 'svn' 
    7375 
     76    def init(self): 
     77        """ Hook for modifying settings or class attributes before 
     78        any methods are called. """ 
     79        pass  
     80 
    7481    def create_repo(self): 
    7582        """Hook for creating the repository.""" 
    7683        # The default test environment does not include a source repo 
     
    108115        self._tracadmin('initenv', 'testenv%s' % self.port, 
    109116                        self.dburi, self.repotype, 
    110117                        self.repo_path_for_initenv()) 
    111         if call([sys.executable, './contrib/htpasswd.py', "-c", "-b", 
    112                  self.htpasswd, "admin", "admin"], close_fds=close_fds, 
     118        if call([sys.executable, 
     119                 os.path.join(self.trac_src, 'contrib', 'htpasswd.py'), "-c", 
     120                 "-b", self.htpasswd, "admin", "admin"], close_fds=close_fds, 
    113121                 cwd=self.command_cwd): 
    114122            raise Exception('Unable to setup admin password') 
    115123        self.adduser('user') 
     
    125133    def adduser(self, user): 
    126134        """Add a user to the environment.  The password will be set to the 
    127135        same as username.""" 
    128         if call([sys.executable, './contrib/htpasswd.py', '-b', self.htpasswd, 
     136        if call([sys.executable, os.path.join(self.trac_src, 'contrib', 
     137                 'htpasswd.py'), '-b', self.htpasswd, 
    129138                 user, user], close_fds=close_fds, cwd=self.command_cwd): 
    130139            raise Exception('Unable to setup password for user "%s"' % user) 
    131140 
    132141    def _tracadmin(self, *args): 
    133142        """Internal utility method for calling trac-admin""" 
    134         proc = Popen([sys.executable, "./trac/admin/console.py", self.tracdir] 
     143        proc = Popen([sys.executable, os.path.join(self.trac_src, 'trac', 
     144                      'admin', 'console.py'), self.tracdir] 
    135145                      + list(args), stdout=PIPE, stderr=STDOUT, 
    136146                      close_fds=close_fds, cwd=self.command_cwd) 
    137147        out = proc.communicate()[0] 
     
    151161                   "--basic-auth=trac,%s," % self.htpasswd] 
    152162        if 'TRAC_TEST_TRACD_OPTIONS' in os.environ: 
    153163            options += os.environ['TRAC_TEST_TRACD_OPTIONS'].split() 
    154         server = Popen([exe, "./trac/web/standalone.py"] + options + 
    155                        [self.tracdir], 
     164        server = Popen([exe, os.path.join(self.trac_src, 'trac', 'web', 
     165                       'standalone.py')] + options + [self.tracdir], 
    156166                       stdout=logfile, stderr=logfile, 
    157167                       close_fds=close_fds, 
    158168                       cwd=self.command_cwd,