9 |
9 |
10 # imported by default to simplify further import statements |
10 # imported by default to simplify further import statements |
11 from logilab.common.testlib import unittest_main, with_tempdir, InnerTest |
11 from logilab.common.testlib import unittest_main, with_tempdir, InnerTest |
12 |
12 |
13 import os |
13 import os |
|
14 from os.path import expanduser |
14 import cubicweb |
15 import cubicweb |
15 from cubicweb.view import StartupView |
16 from cubicweb.view import StartupView |
16 from cubicweb.web.controller import Controller |
17 from cubicweb.web.controller import Controller |
17 from cubicweb.devtools.httptest import CubicWebServerTC |
18 from cubicweb.devtools.httptest import CubicWebServerTC |
18 |
19 |
51 self._profile_name = self.profile_name_mask % self._profile_data |
52 self._profile_name = self.profile_name_mask % self._profile_data |
52 fnull = open(os.devnull, 'w') |
53 fnull = open(os.devnull, 'w') |
53 stdout = TemporaryFile() |
54 stdout = TemporaryFile() |
54 stderr = TemporaryFile() |
55 stderr = TemporaryFile() |
55 try: |
56 try: |
56 check_call(['firefox', '-no-remote', '-CreateProfile', |
57 home = expanduser('~') |
57 '%s %s' % (self._profile_name, self._tmp_dir)], |
58 user = os.getlogin() |
58 stdout=stdout, stderr=stderr) |
59 assert os.access(home, os.W_OK), \ |
|
60 'No write access to your home directory, Firefox will crash.'\ |
|
61 ' Are you sure "%s" is a valid home for user "%s"' % (home, user) |
|
62 check_call(['firefox', '-no-remote', '-CreateProfile', |
|
63 '%s %s' % (self._profile_name, self._tmp_dir)], |
|
64 stdout=stdout, stderr=stderr) |
59 except CalledProcessError, cpe: |
65 except CalledProcessError, cpe: |
60 stdout.seek(0) |
66 stdout.seek(0) |
61 stderr.seek(0) |
67 stderr.seek(0) |
62 raise VerboseCalledProcessError(cpe.returncode, cpe.cmd, stdout.read(), stderr.read()) |
68 raise VerboseCalledProcessError(cpe.returncode, cpe.cmd, stdout.read(), stderr.read()) |
63 |
|
64 |
69 |
65 def start(self, url): |
70 def start(self, url): |
66 self.stop() |
71 self.stop() |
67 fnull = open(os.devnull, 'w') |
72 fnull = open(os.devnull, 'w') |
68 self._process = Popen(['firefox', '-no-remote', '-P', self._profile_name, url], |
73 self._process = Popen(['firefox', '-no-remote', '-P', self._profile_name, url], |