예제 #1
0
def test_open_file():
    with open(os.path.join(TEST_DIR, 'empty.html')) as f:
        p = Parser(doc=f)

    assert_true(p.__doc__ is not None)
    assert_true(type(p) is not None)
    assert_true(type(p.to_dict()) is dict)
예제 #2
0
파일: test_parser.py 프로젝트: kylewm/mf2py
def test_person_with_url():
    p = Parser(doc=open("test/examples/person_with_url.html"))
    result = p.to_dict()
    assert_equal(result["items"][0]["properties"]["name"],
                 ['Tom Morris'])
    assert_equal(result["items"][0]["properties"]["url"],
                 ['http://tommorris.org/'])
예제 #3
0
파일: test_parser.py 프로젝트: sgml/mf2py
def test_person_with_url():
    p = Parser(doc=open("test/examples/person_with_url.html"))
    result = p.to_dict()
    assert_equal(result["items"][0]["properties"]["name"],
                 ['Tom Morris'])
    assert_equal(result["items"][0]["properties"]["url"],
                 ['http://tommorris.org/'])
예제 #4
0
def test_doc_tag_backcompat():
    # test that strings, BS doc and BS tags are all parsed and in the latter cases copies are made and are modified by backcompat
    doc = '''<article class="hentry"></article>'''
    soup = BeautifulSoup(doc)

    parse_string = Parser(doc).to_dict()
    assert_true('h-entry' in parse_string['items'][0]['type'])

    p = Parser(soup)
    assert_true('h-entry' in p.to_dict()['items'][0]['type'])
    assert_false(soup is p.__doc__)
    assert_false(soup == p.__doc__)

    p = Parser(soup.article)
    assert_true('h-entry' in p.to_dict()['items'][0]['type'])
    assert_false(soup.article is p.__doc__)
    assert_false(soup.article == p.__doc__)
예제 #5
0
def test_empty():
    p = Parser()
    assert_true(type(p) is not None)
    assert_true(type(p.to_dict()) is dict)
예제 #6
0
def parse_fixture(path, url=None):
    with open(os.path.join(TEST_DIR, path)) as f:
        p = Parser(doc=f, url=url, html_parser='html5lib')
        return p.to_dict()
예제 #7
0
파일: test_parser.py 프로젝트: kylewm/mf2py
def test_simple_person_reference_implied():
    p = Parser(doc=open("test/examples/simple_person_reference_implied.html"))
    result = p.to_dict()
    assert_equal(result["items"][0]["properties"],
                 {'name': ['Frances Berriman']})
예제 #8
0
파일: test_parser.py 프로젝트: kylewm/mf2py
def test_open_file():
    p = Parser(doc=open("test/examples/empty.html"))
    assert_true(p.__doc__ is not None)
    assert_true(type(p) is not None)
    assert_true(type(p.to_dict()) is dict)
예제 #9
0
파일: test_parser.py 프로젝트: kylewm/mf2py
def parse_fixture(path, url=None):
    with open(os.path.join("test/examples/", path)) as f:
        p = Parser(doc=f, url=url, html_parser='html5lib')
        return p.to_dict()
예제 #10
0
파일: test_parser.py 프로젝트: sgml/mf2py
def test_simple_person_reference_implied():
    p = Parser(doc=open("test/examples/simple_person_reference_implied.html"))
    result = p.to_dict()
    assert_equal(result["items"][0]["properties"],
                 {'name': ['Frances Berriman']})
예제 #11
0
파일: test_parser.py 프로젝트: sgml/mf2py
def test_open_file():
    p = Parser(doc=open("test/examples/empty.html"))
    assert_true(p.__doc__ is not None)
    assert_true(type(p) is not None)
    assert_true(type(p.to_dict()) is dict)
예제 #12
0
파일: test_parser.py 프로젝트: sgml/mf2py
def parse_fixture(path, url=None):
    with open(os.path.join("test/examples/", path)) as f:
        p = Parser(doc=f, url=url, html_parser='html5lib')
        return p.to_dict()