def test_quirks_warn_relative_combinator(self): """Test that quirks mode raises a warning with relative combinator.""" sv.purge() with warnings.catch_warnings(record=True) as w: # Cause all warnings to always be triggered. warnings.simplefilter("always") # Trigger a warning. sv.compile('> p', flags=sv._QUIRKS) # Verify some things self.assertTrue(len(w) == 1) self.assertTrue(issubclass(w[-1].category, sv_util.QuirksWarning))
def test_cache(self): """Test cache.""" sv.purge() self.assertEqual(sv.cp._cached_css_compile.cache_info().currsize, 0) for x in range(1000): value = '[value="{}"]'.format(sv_util.ustr(random.randint(1, 10000))) p = sv.compile(value) self.assertTrue(p.pattern == value) self.assertTrue(sv.cp._cached_css_compile.cache_info().currsize > 0) self.assertTrue(sv.cp._cached_css_compile.cache_info().currsize == 500) sv.purge() self.assertEqual(sv.cp._cached_css_compile.cache_info().currsize, 0)
def test_contains_warn(self): """Test old alias raises a warning.""" sv.purge() with warnings.catch_warnings(record=True) as w: # Cause all warnings to always be triggered. warnings.simplefilter("always") # Trigger a warning. self.assert_selector(self.MARKUP, 'body span:contains(that)', ['2'], flags=util.HTML) # Verify some things self.assertTrue(len(w) == 1) self.assertTrue(issubclass(w[-1].category, FutureWarning))
def setUp(self): """Setup.""" sv.purge() self.quirks = True
def purge(self): """Purge cache.""" sv.purge()
def setUp(self): """Setup.""" sv.purge()