From 98b6fe29066a165f5109f0f68f0f3f8c912c205b Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 31 Mar 2020 01:30:02 +0200 Subject: [PATCH] Fixed flakes --- panel/io/state.py | 2 + panel/models/location.py | 48 +++++++++-------- panel/tests/models/test_location.py | 82 ++++++++++++----------------- panel/util.py | 2 +- 4 files changed, 64 insertions(+), 70 deletions(-) diff --git a/panel/io/state.py b/panel/io/state.py index 87ba3ee45b..51003cca7e 100644 --- a/panel/io/state.py +++ b/panel/io/state.py @@ -49,6 +49,8 @@ class _state(param.Parameterized): # Stores a set of locked Websockets, reset after every change event _locks = WeakSet() + _curdoc = None + def __repr__(self): server_info = [] for server, panel, docs in self._servers.values(): diff --git a/panel/models/location.py b/panel/models/location.py index b3cfca5d72..f220f881f6 100644 --- a/panel/models/location.py +++ b/panel/models/location.py @@ -1,37 +1,41 @@ """This module provides a Bokeh Location Model as a wrapper around the JS window.location api""" -import pathlib -from typing import List, Optional - -import param - -from bokeh.core.properties import Bool, Instance, Int, String -from bokeh.layouts import column +from bokeh.core.properties import Bool, String from bokeh.models import Model class Location(Model): - """A python wrapper around the JS `window.location` api. See + """ + A python wrapper around the JS `window.location` api. See https://www.w3schools.com/js/js_window_location.asp and https://www.w3.org/TR/html52/browsers.html#the-location-interface - You can use this model to provide (parts of) the app state to the user as a bookmarkable and - shareable link. + You can use this model to provide (parts of) the app state to the + user as a bookmarkable and shareable link. """ - href = String(default="", help="The full url, e.g. 'https://localhost:80?color=blue#interact'") + href = String(default="", help=""" + The full url, e.g. 'https://localhost:80?color=blue#interact'""") + + hostname = String(default="", help=""" + hostname in window.location e.g. 'panel.holoviz.org'""") + + pathname = String(default="", help=""" + pathname in window.location e.g. '/user_guide/Interact.html'""") + + protocol = String(default="", help=""" + protocol in window.location e.g. 'https'""") - hostname = String(default="", help="hostname in window.location e.g. 'panel.holoviz.org'") + port = String(default="", help=""" + port in window.location e.g. 80""") - pathname = String(default="", help="pathname in window.location e.g. '/user_guide/Interact.html'") + search = String(default="", help=""" + search in window.location e.g. '?color=blue'""") - protocol = String(default="", help="protocol in window.location e.g. 'https'") - port = String(default="", help="port in window.location e.g. 80") - search = String(default="", help="search in window.location e.g. '?color=blue'") - hash_ = String(default="", help="hash in window.location e.g. '#interact'") + hash_ = String(default="", help=""" + hash in window.location e.g. '#interact'""") - reload = Bool( - default=True, - help="""Reload the page when the location is updated. For multipage apps this should be \ - set to True, For single page apps this should be set to False""", - ) + reload = Bool(default=True, help=""" + Reload the page when the location is updated. For multipage apps + this should be set to True, For single page apps this should be + set to False""") diff --git a/panel/tests/models/test_location.py b/panel/tests/models/test_location.py index 52c0efac81..b8ccaea639 100644 --- a/panel/tests/models/test_location.py +++ b/panel/tests/models/test_location.py @@ -1,47 +1,35 @@ -"""In this module we test the Bokeh Location Model""" - -import pytest -import panel as pn -from panel.models.location import Location - - -def test_constructor(): - # When - actual = Location() - # Then - assert actual.href == "" - assert actual.hostname == "" - assert actual.pathname == "" - assert actual.protocol == "" - assert actual.port == "" - assert actual.search == "" - assert actual.hash_ == "" - assert actual.reload == True - - -def test_constructor_with__href(): - # Given - href = "https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact" - # When - actual = Location( - href="https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact" - ) - # Then - assert actual.href == href - assert actual.hostname == "" - assert actual.pathname == "" - assert actual.protocol == "" - assert actual.port == "" - assert actual.search == "" - assert actual.hash_ == "" - assert actual.reload == True - - -def test_manual(): - bkmodel = pn.pane.Bokeh(Location()) - app = pn.Column(bkmodel) - return app - - -if __name__.startswith("bk"): - test_manual().servable() +import panel as pn + +from panel.models.location import Location + + +def test_constructor(): + # When + actual = Location() + # Then + assert actual.href == "" + assert actual.hostname == "" + assert actual.pathname == "" + assert actual.protocol == "" + assert actual.port == "" + assert actual.search == "" + assert actual.hash_ == "" + assert actual.reload == True + + +def test_constructor_with__href(): + # Given + href = "https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact" + # When + actual = Location( + href="https://panel.holoviz.org/user_guide/Interact.html:80?color=blue#interact" + ) + # Then + assert actual.href == href + assert actual.hostname == "" + assert actual.pathname == "" + assert actual.protocol == "" + assert actual.port == "" + assert actual.search == "" + assert actual.hash_ == "" + assert actual.reload == True diff --git a/panel/util.py b/panel/util.py index e904a374c5..d7adb85573 100644 --- a/panel/util.py +++ b/panel/util.py @@ -298,7 +298,7 @@ def edit_readonly(parameterized): p.constant = False try: yield - except: + except Exception: raise finally: for (p, readonly) in zip(params, readonlys):