style: normalize test file indentation
This commit is contained in:
30
test_nobs.py
30
test_nobs.py
@@ -9,11 +9,11 @@ FAIL = "[FAIL]"
|
|||||||
# Test 1: Import soup_parser
|
# Test 1: Import soup_parser
|
||||||
print("Test 1: Import soup_parser")
|
print("Test 1: Import soup_parser")
|
||||||
try:
|
try:
|
||||||
import soup_parser
|
import soup_parser
|
||||||
print(" %s soup_parser imported" % OK)
|
print(" %s soup_parser imported" % OK)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(" %s Failed: %s" % (FAIL, e))
|
print(" %s Failed: %s" % (FAIL, e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Test 2: Check bs4 availability detection
|
# Test 2: Check bs4 availability detection
|
||||||
print("Test 2: Check bs4 availability")
|
print("Test 2: Check bs4 availability")
|
||||||
@@ -39,29 +39,29 @@ links = soup.find_all('a', href=True)
|
|||||||
|
|
||||||
print(" Found %d links with href" % len(links))
|
print(" Found %d links with href" % len(links))
|
||||||
if len(links) == 2:
|
if len(links) == 2:
|
||||||
print(" %s Correct count" % OK)
|
print(" %s Correct count" % OK)
|
||||||
else:
|
else:
|
||||||
print(" %s Expected 2, got %d" % (FAIL, len(links)))
|
print(" %s Expected 2, got %d" % (FAIL, len(links)))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Test 4: Verify link attributes
|
# Test 4: Verify link attributes
|
||||||
print("Test 4: Verify link attributes")
|
print("Test 4: Verify link attributes")
|
||||||
for i, link in enumerate(links):
|
for i, link in enumerate(links):
|
||||||
href = link['href']
|
href = link['href']
|
||||||
print(" Link %d: %s" % (i+1, href))
|
print(" Link %d: %s" % (i+1, href))
|
||||||
if not href.startswith('http://example.com/'):
|
if not href.startswith('http://example.com/'):
|
||||||
print(" %s Unexpected href" % FAIL)
|
print(" %s Unexpected href" % FAIL)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
print(" %s All hrefs correct" % OK)
|
print(" %s All hrefs correct" % OK)
|
||||||
|
|
||||||
# Test 5: Test attrs access (used by fetch.py)
|
# Test 5: Test attrs access (used by fetch.py)
|
||||||
print("Test 5: Test attrs dict access")
|
print("Test 5: Test attrs dict access")
|
||||||
link = links[1]
|
link = links[1]
|
||||||
if 'rel' in link.attrs:
|
if 'rel' in link.attrs:
|
||||||
print(" %s rel attribute found: %s" % (OK, link.attrs['rel']))
|
print(" %s rel attribute found: %s" % (OK, link.attrs['rel']))
|
||||||
else:
|
else:
|
||||||
print(" %s rel attribute missing" % FAIL)
|
print(" %s rel attribute missing" % FAIL)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
print("All tests passed!")
|
print("All tests passed!")
|
||||||
|
|||||||
Reference in New Issue
Block a user