Add Activity Testing API and check command to setup.py
./setup.py check now invokes tests in tests/ directory. tests directory should have integration(UI tests) and unit(unit tests) sub directories, but it isn't necessary to have any dir. of the above.
This commit is contained in:
committed by
Daniel Narvaez
parent
d4b4405c6c
commit
29738c9087
@@ -22,14 +22,26 @@ from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
import subprocess
|
||||
from contextlib import contextmanager
|
||||
|
||||
from sugar3.test import uitree
|
||||
|
||||
import dbus
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
bus = dbus.SessionBus()
|
||||
|
||||
|
||||
class UITestCase(unittest.TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
unittest.TestCase(*args, **kwargs)
|
||||
|
||||
self.bundle_id = None
|
||||
|
||||
def setUp(self):
|
||||
logger = logging.getLogger()
|
||||
self._orig_level = logger.getEffectiveLevel()
|
||||
@@ -51,3 +63,19 @@ class UITestCase(unittest.TestCase):
|
||||
raise
|
||||
finally:
|
||||
process.terminate()
|
||||
|
||||
@contextmanager
|
||||
def run_activity(self):
|
||||
if bundle_id is not None:
|
||||
process = subprocess.Popen(["sugar-launch", self.bundle_id])
|
||||
else:
|
||||
print "No bundle_id specified."
|
||||
return
|
||||
|
||||
try:
|
||||
yield
|
||||
except:
|
||||
logging.debug(uitree.get_root().dump())
|
||||
raise
|
||||
finally:
|
||||
process.terminate()
|
||||
|
||||
Reference in New Issue
Block a user