def explain(text, edge_size): error_template = get_template('error.html') if edge_size > 0: text = find_jquery_selector(text, edge_size) if is_selector(text): explanations = css_explain(text) examples = generate_examples(text) explanation = css_render(explanations, examples) else: explanation = error_template.render(Context({'text': text, 'type': 'CSS selector'})) return explanation
def explain(text, edge_size): error_template = get_template('error.html') if edge_size > 0: text = find_jquery_selector(text, edge_size) if is_selector(text): explanations = css_explain(text) examples = generate_examples(text) explanation = css_render(explanations, examples) else: explanation = error_template.render( Context({ 'text': text, 'type': 'CSS selector' })) return explanation
def test_if_no_quotes_return_string(self): s = find_jquery_selector(' word ', 3) self.assertEqual(s, 'word')
def test_choose_closest_quotes_from_inside(self): s = find_jquery_selector(' "\'word\'" ', 8) self.assertEqual(s, 'word')
def test_choose_closest_quotes_from_outside(self): s = find_jquery_selector(' "\'word\'" ', 3) self.assertEqual(s, "'word'")
def test_string_in_double_quotes(self): s = find_jquery_selector(' "word" ', 7) self.assertEqual(s, 'word')
def test_find_jquery_selector_offset_to_right(self): s = find_jquery_selector(" 'word' ", 5) self.assertEqual(s, 'word')
def test_find_external_string(self): s = find_jquery_selector(" 'word' ", 7) self.assertEqual(s, 'word')