Skip to content

Commit

Permalink
Prepare tests and README for extensions (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelogladding authored Nov 30, 2023
1 parent f6afda7 commit 70bbb6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Parse content from a URL:
obj = mf2py.parse(url="http://tommorris.org/")
```

### Extensions

---

`parse` is a convenience method that actually delegates to
`mf2py.Parser` to do the real work. More sophisticated behaviors are
available by invoking the object directly.
Expand Down
10 changes: 5 additions & 5 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
TEST_DIR = "test/examples/"


def parse_fixture(path, url=None):
def parse_fixture(path, **kwargs):
with open(os.path.join(TEST_DIR, path)) as f:
p = Parser(doc=f, url=url, html_parser="html5lib")
p = Parser(doc=f, html_parser="html5lib", **kwargs)
return p.to_dict()


Expand Down Expand Up @@ -338,14 +338,14 @@ def test_enclosures():


def test_empty_href():
result = parse_fixture("hcard_with_empty_url.html", "http://foo.com")
result = parse_fixture("hcard_with_empty_url.html", url="http://foo.com")

for hcard in result["items"]:
assert ["http://foo.com"] == hcard["properties"]["url"]


def test_link_with_u_url():
result = parse_fixture("link_with_u-url.html", "http://foo.com")
result = parse_fixture("link_with_u-url.html", url="http://foo.com")
assert {
"type": ["h-card"],
"properties": {
Expand All @@ -356,7 +356,7 @@ def test_link_with_u_url():


def test_broken_url():
result = parse_fixture("broken_url.html", "http://example.com")
result = parse_fixture("broken_url.html", url="http://example.com")
assert (
result["items"][0]["properties"]["relative"][0] == "http://example.com/foo.html"
)
Expand Down

0 comments on commit 70bbb6a

Please sign in to comment.