|
1 | 1 | """Test expanders for shorthand properties."""
|
2 | 2 |
|
3 |
| -import math |
| 3 | +from math import pi |
4 | 4 |
|
5 | 5 | import pytest
|
6 | 6 | import tinycss2
|
@@ -223,8 +223,7 @@ def test_size_invalid(rule):
|
223 | 223 | ('transform: none', {'transform': ()}),
|
224 | 224 | ('transform: translate(6px) rotate(90deg)', {
|
225 | 225 | 'transform': (
|
226 |
| - ('translate', ((6, 'px'), (0, 'px'))), |
227 |
| - ('rotate', math.pi / 2))}), |
| 226 | + ('translate', ((6, 'px'), (0, 'px'))), ('rotate', pi / 2))}), |
228 | 227 | ('transform: translate(-4px, 0)', {
|
229 | 228 | 'transform': (('translate', ((-4, 'px'), (0, None))),)}),
|
230 | 229 | ('transform: translate(6px, 20%)', {
|
@@ -818,7 +817,6 @@ def test_linear_gradient():
|
818 | 817 | red = (1, 0, 0, 1)
|
819 | 818 | lime = (0, 1, 0, 1)
|
820 | 819 | blue = (0, 0, 1, 1)
|
821 |
| - pi = math.pi |
822 | 820 |
|
823 | 821 | def gradient(css, direction, colors=(blue,), stop_positions=(None,)):
|
824 | 822 | for repeating, prefix in ((False, ''), (True, 'repeating-')):
|
@@ -1218,3 +1216,34 @@ def test_text_align(rule, result):
|
1218 | 1216 | ))
|
1219 | 1217 | def test_text_align_invalid(rule, reason):
|
1220 | 1218 | assert_invalid(rule, reason)
|
| 1219 | + |
| 1220 | + |
| 1221 | +@assert_no_logs |
| 1222 | +@pytest.mark.parametrize('rule, result', ( |
| 1223 | + ('image-orientation: none', {'image_orientation': 'none'}), |
| 1224 | + ('image-orientation: from-image', {'image_orientation': 'from-image'}), |
| 1225 | + ('image-orientation: 90deg', {'image_orientation': (pi / 2, False)}), |
| 1226 | + ('image-orientation: 30deg', {'image_orientation': (pi / 6, False)}), |
| 1227 | + ('image-orientation: 180deg flip', {'image_orientation': (pi, True)}), |
| 1228 | + ('image-orientation: 0deg flip', {'image_orientation': (0, True)}), |
| 1229 | + ('image-orientation: flip 90deg', {'image_orientation': (pi / 2, True)}), |
| 1230 | + ('image-orientation: flip', {'image_orientation': (0, True)}), |
| 1231 | +)) |
| 1232 | +def test_image_orientation(rule, result): |
| 1233 | + assert expand_to_dict(rule) == result |
| 1234 | + |
| 1235 | +@assert_no_logs |
| 1236 | +@pytest.mark.parametrize('rule, reason', ( |
| 1237 | + ('image-orientation: none none', 'invalid'), |
| 1238 | + ('image-orientation: unknown', 'invalid'), |
| 1239 | + ('image-orientation: none flip', 'invalid'), |
| 1240 | + ('image-orientation: from-image flip', 'invalid'), |
| 1241 | + ('image-orientation: 10', 'invalid'), |
| 1242 | + ('image-orientation: 10 flip', 'invalid'), |
| 1243 | + ('image-orientation: flip 10', 'invalid'), |
| 1244 | + ('image-orientation: flip flip', 'invalid'), |
| 1245 | + ('image-orientation: 90deg flop', 'invalid'), |
| 1246 | + ('image-orientation: 90deg 180deg', 'invalid'), |
| 1247 | +)) |
| 1248 | +def test_image_orientation_invalid(rule, reason): |
| 1249 | + assert_invalid(rule, reason) |
0 commit comments