Falko Schindler 2 år sedan
förälder
incheckning
2257d4c44f
2 ändrade filer med 12 tillägg och 14 borttagningar
  1. 3 3
      tests/conftest.py
  2. 9 11
      tests/test_pages.py

+ 3 - 3
tests/conftest.py

@@ -33,11 +33,11 @@ def selenium(selenium: webdriver.Chrome) -> webdriver.Chrome:
 
 @pytest.fixture(autouse=True)
 def reset_globals() -> Generator[None, None, None]:
-    WebPage.instances = {}
-    WebPage.sockets = {}
+    WebPage.sockets.clear()
+    WebPage.instances.clear()
     WebPage.next_page_id = 0
+    JustpyBaseComponent.instances.clear()
     JustpyBaseComponent.next_id = 0
-    JustpyBaseComponent.instances = {}
     jp.component_file_list = jp.create_component_file_list()
     jp.template_options['component_file_list'] = jp.component_file_list
     importlib.reload(globals)

+ 9 - 11
tests/test_pages.py

@@ -65,8 +65,8 @@ def test_automatic_loading_of_joystick_dependency(user: User):
 
     user.open('/')
     srcs = user.get_attributes('script', 'src')
-    assert any(('joystick.js' in s) for s in srcs)
-    assert any(('nipplejs.min.js' in s) for s in srcs)
+    assert any(s.endswith('joystick.js') for s in srcs)
+    assert any(s.endswith('nipplejs.min.js') for s in srcs)
 
 
 def test_automatic_loading_of_keyboard_dependency_before_startup(user: User):
@@ -75,12 +75,11 @@ def test_automatic_loading_of_keyboard_dependency_before_startup(user: User):
         ui.keyboard()
 
     user.open('/')
-    assert any(('keyboard.js' in s) for s in user.get_attributes('script', 'src'))
+    assert any(s.endswith('keyboard.js') for s in user.get_attributes('script', 'src'))
     user.sleep(2)  # NOTE we need to sleep here so the js timeout error is printed (start pytest with -s to see it)
 
 
 def test_automatic_loading_of_keyboard_dependency_after_startup(user: User):
-
     @ui.page('/')
     def page():
         ui.button('activate keyboard', on_click=lambda: ui.keyboard())
@@ -93,23 +92,22 @@ def test_automatic_loading_of_keyboard_dependency_after_startup(user: User):
 
 
 def test_shared_and_individual_pages(user: User):
-
     @ui.page('/individual_page')
     def individual_page():
-        ui.label(f'your individual page with uuid {uuid4()}')
+        ui.label(f'individual page with uuid {uuid4()}')
 
     @ ui.page('/shared_page', shared=True)
     def shared_page():
-        ui.label(f'a shared page with uuid {uuid4()}')
+        ui.label(f'shared page with uuid {uuid4()}')
 
     user.open('/shared_page')
-    uuid1 = user.find('a shared page').text.split(' ')[-1]
+    uuid1 = user.find('shared page').text.split()[-1]
     user.open('/shared_page')
-    uuid2 = user.find('a shared page').text.split(' ')[-1]
+    uuid2 = user.find('shared page').text.split()[-1]
     assert uuid1 == uuid2
 
     user.open('/individual_page')
-    uuid1 = user.find('your individual page').text.split(' ')[-1]
+    uuid1 = user.find('individual page').text.split()[-1]
     user.open('/individual_page')
-    uuid2 = user.find('your individual page').text.split(' ')[-1]
+    uuid2 = user.find('individual page').text.split()[-1]
     assert uuid1 != uuid2