def notrailtester(runtime, n=4): html_filename = os.path.join(tempfile.gettempdir(), 'flexx_empty_page.html') with open(html_filename, 'wb') as f: f.write('<html><body>test page</body></html>'.encode()) # Give a chance for common stuff to init x = webruntime.launch(html_filename, runtime) time.sleep(0.5) x.close() before = index() for i in range(n): x = webruntime.launch(html_filename, runtime) time.sleep(1.5) x.close() time.sleep(0.5) after = index() extra_files = after.difference(before) extra_files2 = [ f for f in extra_files if not f.startswith((webruntime.TEMP_APP_DIR, webruntime.RUNTIME_DIR)) ] print(extra_files2) assert len(extra_files2) < n
def notrailtester(runtime, n=4): html_filename = os.path.join(tempfile.gettempdir(), 'flexx_empty_page.html') with open(html_filename, 'wb') as f: f.write('<html><body>test page</body></html>'.encode()) # Give a chance for common stuff to init x = webruntime.launch(html_filename, runtime) time.sleep(0.5) x.close() before = index() for i in range(n): x = webruntime.launch(html_filename, runtime) time.sleep(1.5) x.close() time.sleep(0.5) after = index() extra_files = after.difference(before) extra_files2 = [f for f in extra_files if not f.startswith((webruntime.TEMP_APP_DIR, webruntime.RUNTIME_DIR))] print(extra_files2) assert len(extra_files2) < n
def test_selenium(): p = launch(URL, 'selenium-firefox') assert p._proc is None assert p.driver time.sleep(0.5) p.close() pytest.raises(ValueError, launch, URL, 'selenium')
def test_selenium(): p = launch(URL, "selenium-firefox") assert p._proc is None assert p.driver p.close() pytest.raises(ValueError, launch, URL, "selenium")
def __init__(self, runtime='xul'): #BaseWidget.__init__(self, None) # Init websocket, will be set when a connection is made self._ws = None # Init runtime that is connected with this app instance self._runtime = None # Init self._widget_counter = 0 self._children = [] # While the client is not connected, we keep a queue of # commands, which are send to the client as soon as it connects self._pending_commands = [] # Register this app instance if runtime == '<export>': self._ws = Exporter(self) self.init() elif runtime == 'notebook': manager._add_pending_app_instance(self) elif runtime: manager._add_pending_app_instance(self) init_server() host, port = _tornado_app.serving_at # We associate the runtime with this specific app instance by # including the app id to the url. In this way, it is pretty # much guaranteed that the runtime will connect to *this* app. icon = self._config.icon icon = icon if icon.image_sizes() else None name = self.name + '-' + self.id self._runtime = launch('http://%s:%i/%s/' % (host, port, name), runtime=runtime, size=self.config.size, icon=icon, title=self.config.title) print('Instantiate app %s' % self.__class__.__name__)
def test_xul(): p = launch(URL, 'xul') assert p._proc p.close() p.close() # should do no harm
def test_qtwebkit(): p = launch(URL, 'pyqt') assert p._proc p.close()
def test_default(): p = launch(URL) assert p.__class__.__name__ == 'XulRuntime' p.close()
def test_browser_fallback(): p = launch(URL, 'browser-foo') assert p._proc is None
def test_xul(): p = launch(URL, 'firefox-app') assert p._proc p.close() p.close() # should do no harm
def test_browser_ff(): p = launch(URL, 'browser-firefox') assert p._proc is None
def test_qtwebkit(): p = launch('http://google.com', 'pyqt') assert p._proc p.close()
def test_nwjs(): p = launch(URL, 'nwjs') assert p._proc p.close()
def test_nodejs(): code = 'console.log("hello!")' p = launch(URL, 'nodejs', code=code) assert p._proc p.close()
def test_nwjs(): p = launch(URL, "nwjs") assert p._proc p.close()
def test_browser(): p = launch(URL, "browser") assert p._proc is None
from flexx.webruntime import launch # Define icon icon = None #icondir = r'C:\almar\iep\iep\resources\appicons/' #icondir = '/home/almar/projects/pyapps/iep/default/iep/resources/appicons/' #icondir = '/Users/almar/py/iep/iep/resources/appicons/' #icon = icondir + 'ieplogo.ico' #target = 'file:///home/almar/projects/pylib/flexx/flexx/exp/learn_html5.html' target = 'http://python.org' rt1 = launch(target, 'xul', title='my xul app', icon=icon) #rt2 = launch('http://python.org')
def test_chomeapp(): p = launch(URL, 'chromeapp') assert p._proc p.close()
def test_browser(): p = launch(URL, 'browser') assert p._proc is None