Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/runalltests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runalltests.py')
-rwxr-xr-xtests/runalltests.py69
1 files changed, 38 insertions, 31 deletions
diff --git a/tests/runalltests.py b/tests/runalltests.py
index f59200f..9a7c8f8 100755
--- a/tests/runalltests.py
+++ b/tests/runalltests.py
@@ -27,19 +27,20 @@ import gobject
logging.basicConfig(level=logging.WARN,
- format="%(asctime)-15s %(name)s %(levelname)s: %(message)s",
- stream=sys.stderr)
+ format='%(asctime)-15s %(name)s %(levelname)s:'
+ ' %(message)s',
+ stream=sys.stderr)
DOCTESTS = [
- "basic_api_v2.txt",
+ 'basic_api_v2.txt',
]
DOCTEST_OPTIONS = doctest.ELLIPSIS
DOCTEST_OPTIONS |= doctest.REPORT_ONLY_FIRST_FAILURE
-DS_DBUS_SERVICE = "org.laptop.sugar.DataStore"
-DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore"
-DS_DBUS_PATH = "/org/laptop/sugar/DataStore"
+DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore'
+DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore'
+DS_DBUS_PATH = '/org/laptop/sugar/DataStore'
ENVIRONMENT_WHITELIST = [
'LD_LIBRARY_PATH',
@@ -48,6 +49,13 @@ ENVIRONMENT_WHITELIST = [
'SUGAR_LOGGER_LEVEL',
]
+SERVICE_TEMPLATE = """
+[D-BUS Service]
+Name = org.laptop.sugar.DataStore
+Exec = %s/bin/datastore-service
+"""
+
+
def setup():
"""Prepare for testing and return environment.
@@ -69,18 +77,16 @@ def setup():
basedir = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), '..')
python_path = [os.path.join(basedir, 'src')] + python_path
environment['PYTHONPATH'] = ':'.join(python_path)
- environment['PATH'] = os.path.join(basedir, 'bin')+':'+os.environ['PATH']
-
- servicedir = os.path.join(environment['HOME'], 'dbus-1', 'services')
- servicepath = os.path.join(servicedir, 'org.laptop.sugar.DataStore.service')
- os.makedirs(servicedir)
- servicefile = file(servicepath, 'w')
- servicefile.write("""
- [D-BUS Service]
- Name = org.laptop.sugar.DataStore
- Exec = %s/bin/datastore-service
- """.replace(' ', '') % (basedir, ))
- servicefile.close()
+ environment['PATH'] = ':'.join([os.path.join(basedir, 'bin'),
+ os.environ['PATH']])
+
+ service_dir = os.path.join(environment['HOME'], 'dbus-1', 'services')
+ service_path = os.path.join(service_dir,
+ 'org.laptop.sugar.DataStore.service')
+ os.makedirs(service_dir)
+ service_file = file(service_path, 'w')
+ service_file.write(SERVICE_TEMPLATE % (basedir, ))
+ service_file.close()
environment['XDG_DATA_DIRS'] = environment['HOME']
os.setpgid(0, 0)
@@ -172,7 +178,7 @@ class TestSuiteWrapper(unittest.TestCase):
def shortDescription(self):
doc = self._wrapped_suite.__doc__
- return doc and doc.split("\n")[0].strip() or None
+ return doc and doc.split('\n')[0].strip() or None
def tearDown(self):
self._kill_data_store()
@@ -180,13 +186,13 @@ class TestSuiteWrapper(unittest.TestCase):
def _kill_data_store(self):
pgrep = subprocess.Popen(['pgrep', '-g', os.environ['DBUS_PID'],
- '-f', 'datastore-service'],
- close_fds=True, stdout=subprocess.PIPE)
+ '-f', 'datastore-service'],
+ close_fds=True, stdout=subprocess.PIPE)
stdout, stderr_ = pgrep.communicate()
pids = stdout.strip().split('\n')
if len(pids) != 1 or not pids[0]:
raise ValueError("Can't find (a single) data store process "
- "(pgrep output %r)" % (stdout, ))
+ "(pgrep output %r)" % (stdout, ))
pid = int(pids[0])
self._loop = gobject.MainLoop()
@@ -212,7 +218,7 @@ class TimedTestResult(unittest._TextTestResult):
# Depending on a private class is bad style, but the only alternative is
# copying it verbatim.
- # pylint: disable-msg=W0212
+ # pylint: disable=W0212
def __init__(self, stream, descriptions, verbosity):
unittest._TextTestResult.__init__(self, stream, descriptions,
@@ -250,7 +256,7 @@ class TimedTestResult(unittest._TextTestResult):
return
if self.showAll:
- self.stream.writeln("ok (%.3fs)" % (run_time, ))
+ self.stream.writeln('ok (%.3fs)' % (run_time, ))
elif self.dots:
self.stream.write('.')
@@ -297,7 +303,8 @@ def run_tests(tests):
def _start_dbus(environment):
pipe = subprocess.Popen(['dbus-launch'], stdout=subprocess.PIPE,
- close_fds=True, env=environment, cwd=environment['HOME'])
+ close_fds=True, env=environment,
+ cwd=environment['HOME'])
stdout, stderr_ = pipe.communicate()
pid = None
address = None
@@ -319,11 +326,11 @@ def _parse_options():
"""Parse command line arguments."""
parser = OptionParser()
parser.add_option('-k', '--keep', dest='keep',
- action='store_true', default=False,
- help='Keep temporary files')
+ action='store_true', default=False,
+ help='Keep temporary files')
parser.add_option('', '--stage2', dest='stage2',
- action='store_true', default=False,
- help='For internal use only')
+ action='store_true', default=False,
+ help='For internal use only')
return parser.parse_args()
@@ -339,8 +346,8 @@ def main(my_name, arguments):
environment['DBUS_PID'] = str(dbus_pid)
pipe = subprocess.Popen([os.path.abspath(my_name),
- '--stage2']+arguments,
- cwd=environment['HOME'], env=environment)
+ '--stage2'] + arguments,
+ cwd=environment['HOME'], env=environment)
return pipe.wait()
finally: