@@ -18,29 +18,37 @@ def test_interval():
1818
1919def test_get_size_from_css (mocker ):
2020 """Test getting the max-width and max-height from something in css"""
21+ # some weird (but valid) css to check we can skip things correctly
2122 test_css = """
2223 Flibble {
24+ padding: 0 0 1px 2px;
25+ color: rgb(3, 4, 555);
2326 min-width : 0;
2427 max-width : 123px;
25- min-height : 0px ;
28+ min-height : 0% ;
2629 max-height : 456px;
27- padding: 0px;
2830 }
2931 """
3032 mocker .patch ("napari.qt.get_current_stylesheet" ).return_value = test_css
31- assert from_napari_css_get_size_of ("Flibble" , (1 , 2 )) == QSize (123 , 456 )
33+ assert from_napari_css_get_size_of ("Flibble" , fallback = (1 , 2 )) == QSize (
34+ 123 , 456
35+ )
3236
3337
3438def test_fallback_if_missing_dimensions (mocker ):
3539 """Test fallback if given something that doesn't have dimensions"""
3640 test_css = " Flobble { background-color: rgb(0, 97, 163); } "
3741 mocker .patch ("napari.qt.get_current_stylesheet" ).return_value = test_css
3842 with pytest .warns (RuntimeWarning , match = "Unable to find DimensionToken" ):
39- assert from_napari_css_get_size_of ("Flobble" , (1 , 2 )) == QSize (1 , 2 )
43+ assert from_napari_css_get_size_of (
44+ "Flobble" , fallback = (1 , 2 )
45+ ) == QSize (1 , 2 )
4046
4147
4248def test_fallback_if_prelude_not_in_css ():
4349 """Test fallback if given something not in the css"""
4450 doesntexist = "AQButtonThatDoesntExist"
4551 with pytest .warns (RuntimeWarning , match = f"Unable to find { doesntexist } " ):
46- assert from_napari_css_get_size_of (doesntexist , (1 , 2 )) == QSize (1 , 2 )
52+ assert from_napari_css_get_size_of (
53+ doesntexist , fallback = (1 , 2 )
54+ ) == QSize (1 , 2 )
0 commit comments