@@ -18,29 +18,37 @@ def test_interval():
18
18
19
19
def test_get_size_from_css (mocker ):
20
20
"""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
21
22
test_css = """
22
23
Flibble {
24
+ padding: 0 0 1px 2px;
25
+ color: rgb(3, 4, 555);
23
26
min-width : 0;
24
27
max-width : 123px;
25
- min-height : 0px ;
28
+ min-height : 0% ;
26
29
max-height : 456px;
27
- padding: 0px;
28
30
}
29
31
"""
30
32
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
+ )
32
36
33
37
34
38
def test_fallback_if_missing_dimensions (mocker ):
35
39
"""Test fallback if given something that doesn't have dimensions"""
36
40
test_css = " Flobble { background-color: rgb(0, 97, 163); } "
37
41
mocker .patch ("napari.qt.get_current_stylesheet" ).return_value = test_css
38
42
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 )
40
46
41
47
42
48
def test_fallback_if_prelude_not_in_css ():
43
49
"""Test fallback if given something not in the css"""
44
50
doesntexist = "AQButtonThatDoesntExist"
45
51
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