def __init__(self, argv): debug = 0 extra_config = None do_list = False use_local = False try: opts, self.arguments = options.getopt(argv, "h?dlLc:") except options.GetoptError as geo: _usage(geo) for opt, optarg in opts: if opt in "h?": _usage() elif opt == "d": debug += 1 elif opt == "l": do_list = True elif opt == "L": use_local = True elif opt == "c": extra_config = optarg globalargs = self.arguments.pop(0) self.config = cf = config.get_config(initdict=globalargs.options, _filename=extra_config) cf.flags.debug = debug cf.flags.use_local = use_local cf.flags.do_list = do_list
def connect(url=None, autocommit=False): if not url: from devtest import config cf = config.get_config() url = cf["database"]["url"] database = util.get_database(url, autocommit=autocommit) return database
def select(self): cf = config.get_config() cf["testbed"] = self._tblist[self._tbselect.index].name if self._persist_cb.value: cf["reportname"] = "jupyter,database" else: cf["reportname"] = "jupyter" selected = [] for idx in self._rselect.index: selected.append(options.OptionSet(self._runnables[idx])) testlist, errlist = loader.load_selections(selected) return cf, testlist
def connect(url=None, autocommit=False): """Initialize the database object to a backend database using the given URL, or what is configured if not provided. """ global database, database_proxy from .util import get_database if database is not None: return if not url: from devtest import config cf = config.get_config() url = cf["database"]["url"] database = get_database(url, autocommit=autocommit) database_proxy.initialize(database)
def start(self, timeout=30): """Start the device side server.""" logging.debug("AutomationServer: attempting to start") cf = config.get_config() runner = cf.uiautomator[self.source].runner cmd = "am instrument -w -e class com.github.uiautomator.stub.Stub " + runner self._adb.command("am force-stop com.github.uiautomator") self._uia_device_process = self._adb.spawn(cmd) timers.nanosleep(1.0) self.forward_port() timers.nanosleep(1.0) while not self.is_alive and timeout > 0: timers.nanosleep(1.0) timeout -= 1 if not self.is_alive: self._uia_device_process.sync_close() self._uia_device_process = None raise UIAutomatorError("RPC server not started!") logging.debug("AutomationServer: started")
def _get_db_url(): from devtest import config s = config.get_config() return s["database"]["url"]
def install(self): cf = config.get_config() base_dir = os.path.dirname(__file__) for apk in cf.uiautomator[self.source].apks: print(apk) # XXX use resource api
def test_with_initdict(self): config._CONFIG = None cf = config.get_config(initdict={"base.tree": "value"}) assert cf.base.tree == "value"
def test_is_singleton(self, cf): newcf = config.get_config() assert id(newcf) == id(cf)
def cf(): return config.get_config()