def test_py26_fallback_on_ordereddict(self): p = soup("""<p><b>a</b> 1<br/> <b>b</b> 2 <b>c</b> 3""").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([('a', '1'), ('b', '2'), ('c', '3')], list(defs.items())) self.assertEqual(True, getattr(defs, '_fake', False))
def populate(self, soup, session, **kw): content = soup.select('#courseRightContent')[0] attrs = parse_homemade_dl(content.select('p small')[0]) self.title = attrs.get('titre') self.begin = attrs.get('du') self.end = attrs.get('au') self.submission_type = attrs.get('type de soumission') self.work_type = attrs.get('type de travail') self.visibility = attrs.get(u'visibilit\xe9 de la soumission') self.assig_id = parse_query(self.path)['assigId'][0]
def populate(self, soup, session, **kw): content = soup.select('#courseRightContent')[0] attrs = parse_homemade_dl(content.select('p small')[0]) self.title = attrs.get('titre') self.begin = attrs.get('du') self.end = attrs.get('au') self.submission_type = attrs.get('type de soumission') self.work_type = attrs.get('type de travail') self.visibility = attrs.get(u'visibilit\xe9 de la soumission') self.assig_id = parse_qs(urlparse(self.path).query)['assigId'][0]
def test_parse_homemade_dl_with_colon_in_key(self): p = soup("<p><b>yo :</b> FOO</p>").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([('yo :', 'FOO')], list(defs.items()))
def test_parse_homemade_dl_uppercase_value(self): p = soup("<p><b>yo</b> FOO</p>").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([('yo', 'FOO')], list(defs.items()))
def test_parse_homemade_dl_uppercase_key(self): p = soup("<p><b>Yo</b> foo</p>").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([('yo', 'foo')], list(defs.items()))
def test_parse_homemade_dl_one_def_child_value(self): p = soup("<p>yo <b>foo</b> <i>bar</i></p>").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([('foo', 'bar')], list(defs.items()))
def test_parse_homemade_dl_def_no_val(self): p = soup("<p>yo <b>title:</b></p>").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([], list(defs.items()))
def test_parse_homemade_dl_no_defs2(self): p = soup("<p>very <i>simple</i> text.</p>").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([], list(defs.items()))
def test_parse_homemade_dl_no_defs(self): p = BeautifulSoup("<p>simple text.</p>").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([], list(defs.items()))
def test_parse_homemade_dl(self): p = soup("""<p><b>a</b> 1<br/> <b>b</b> 2 <b>c</b> 3""").select('p')[0] defs = parse_homemade_dl(p) self.assertSequenceEqual([('a', '1'), ('b', '2'), ('c', '3')], list(defs.items()))