MCPcopy Create free account
hub / github.com/django/code.djangoproject.com / NoShadowTestCase

Class NoShadowTestCase

noshadows.py:119–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118
119class NoShadowTestCase(unittest.TestCase):
120 @classmethod
121 def run_and_exit(cls):
122 """
123 Run all tests on the class and exit with the proper exit status (1 if any failures occured,
124 0 otherwise)
125 """
126 runner = unittest.TextTestRunner()
127 suite = unittest.defaultTestLoader.loadTestsFromTestCase(cls)
128 result = runner.run(suite)
129 retval = 0 if result.wasSuccessful() else 1
130 sys.exit(retval)
131
132 def test_tripletwise(self):
133 self.assertEqual(
134 list(tripletwise("ABCDEF")),
135 [("A", "B", "C"), ("B", "C", "D"), ("C", "D", "E"), ("D", "E", "F")],
136 )
137
138 def test_tripletwise_too_short(self):
139 self.assertEqual(list(tripletwise("AB")), [])
140
141 def test_skip_whitespace(self):
142 rules = parse_stylesheet("html { color: red ; }")
143 self.assertEqual(len(rules), 1)
144 non_whitespace_content = list(skip_whitespace(rules[0].content))
145 self.assertEqual(
146 len(non_whitespace_content), 4
147 ) # attr, colon, value, semicolon
148
149 def test_has_shadow(self):
150 for expected, css in [
151 (True, "html {box-shadow: 10px 5px 5px red;}"),
152 (True, "html {text-shadow: 1px 1px 2px pink;}"),
153 (True, "html {text-shadow: 5px 5px #558ABB;}"),
154 (False, "html {box-shadow: none;}"),
155 (False, "html {text-shadow: none;}"),
156 (True, "html {text-shadow: 5px 5px #558ABB; box-shadow: none;}"),
157 (True, "html {text-shadow: none; box-shadow: 10px 5px 5px red;}"),
158 (False, "html {}"),
159 (False, "html {color: red; font-weight: bold;}"),
160 ]:
161 with self.subTest(css=css, expected=expected):
162 (rule,) = parse_stylesheet(css)
163 assert_method = self.assertTrue if expected else self.assertFalse
164 assert_method(has_shadow(rule))
165
166 def test_selector_str_tag(self):
167 (rule,) = parse_stylesheet("html {}")
168 self.assertEqual(selector_str(rule), "html")
169
170 def test_selector_str_classname(self):
171 (rule,) = parse_stylesheet(".className {}")
172 self.assertEqual(selector_str(rule), ".className")
173
174 def test_selector_str_id(self):
175 (rule,) = parse_stylesheet("#identifier {}")
176 self.assertEqual(selector_str(rule), "#identifier")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected