Skip to content

Commit b577bd5

Browse files
committed
All tests passing.
1 parent d457566 commit b577bd5

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

microdata.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def get_items(location, encoding=None):
2121
except ImportError:
2222
from urllib import urlopen
2323

24-
print "Objects in location", location
2524
dom_builder = html5lib.treebuilders.getTreeBuilder("dom")
2625
parser = html5lib.HTMLParser(tree=dom_builder)
2726
tree = parser.parse(urlopen(location), encoding=encoding)
@@ -114,7 +113,7 @@ def __init__(self, string, domain=""):
114113
if string.startswith("http://") or string.startswith("https://"):
115114
self.string = string
116115
else:
117-
self.string = "http://" + domain + string
116+
self.string = "/".join(("http:", "", domain, string))
118117

119118
def __eq__(self, other):
120119
if isinstance(other, URI):

test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_parse_nested(self):
7171
# test case of a nested itemscope
7272
self.assertTrue(isinstance(item.location, Item))
7373
self.assertEqual(item.location.itemtype, [URI("http://schema.org/Place")])
74-
self.assertEqual(item.location.url, URI("wells-fargo-center.html"))
74+
self.assertEqual(item.location.url, URI("wells-fargo-center.html", domain="test-data"))
7575

7676
# address should be a nested item
7777
self.assertTrue(isinstance(item.location.address, Item))
@@ -82,9 +82,9 @@ def test_parse_nested(self):
8282
i = json.loads(item.json())
8383
self.assertEqual(i["properties"]["name"][0].strip(), "Miami Heat at Philadelphia 76ers - Game 3 (Home Game 1)")
8484
self.assertEqual(i["type"], ["http://schema.org/Event"])
85-
self.assertEqual(i["properties"]["url"], ["nba-miami-philidelphia-game3.html"])
85+
self.assertEqual(i["properties"]["url"], ["http://test-data/nba-miami-philidelphia-game3.html"])
8686
self.assertTrue(isinstance(i["properties"]["location"][0], dict))
87-
self.assertEqual(i["properties"]["location"][0]["properties"]["url"][0], "wells-fargo-center.html")
87+
self.assertEqual(i["properties"]["location"][0]["properties"]["url"][0], "http://test-data/wells-fargo-center.html")
8888
self.assertTrue(isinstance(i["properties"]["location"][0]["properties"]["address"][0], dict))
8989
self.assertEqual(i["properties"]["location"][0]["properties"]["address"][0]["properties"]["addressLocality"][0], "Philadelphia")
9090

0 commit comments

Comments
 (0)