Changed location of test HTML files

This commit is contained in:
Mišo Belica 2013-03-18 21:40:19 +01:00
parent 3b5b2b1522
commit ee483a7f91
13 changed files with 16 additions and 11 deletions

View File

@ -186,7 +186,7 @@ class TestCandidateNodes(unittest.TestCase):
def test_article_enables_candidate_access(self):
"""Candidates are accessible after document processing."""
doc = Article(load_article('ars/ars.001.html'))
doc = Article(load_article('ars.001.html'))
self.assertTrue(hasattr(doc, 'candidates'))
@ -221,7 +221,7 @@ class TestScoringNodes(unittest.TestCase):
"""Processing candidates should get us a list of nodes to try out."""
# we'll start out using our first real test document
test_nodes = []
doc = document_fromstring(load_article('ars/ars.001.html'))
doc = document_fromstring(load_article('ars.001.html'))
for node in doc.getiterator():
if node.tag in ['p', 'td', 'pre']:
test_nodes.append(node)
@ -271,7 +271,7 @@ class TestLinkDensityScoring(unittest.TestCase):
def test_link_density(self):
"""Test that we get a link density"""
doc = document_fromstring(load_article('ars/ars.001.html'))
doc = document_fromstring(load_article('ars.001.html'))
for node in doc.getiterator():
if node.tag in ['p', 'td', 'pre']:
density = get_link_density(node)

View File

@ -1,18 +1,23 @@
from os import path
# -*- coding: utf8 -*-
from __future__ import absolute_import
from __future__ import division, print_function, unicode_literals
from os.path import abspath, dirname, join
TEST_DIR = path.dirname(__file__)
TEST_DIR = abspath(dirname(__file__))
def load_snippet(filename):
"""Helper to fetch in the content of a test snippet"""
file_path = path.join(TEST_DIR, 'test_snippets', filename)
def load_snippet(file_name):
"""Helper to fetch in the content of a test snippet."""
file_path = join(TEST_DIR, "data/snippets", file_name)
with open(file_path) as file:
return file.read()
def load_article(filename):
"""Helper to fetch in the content of a test article"""
file_path = path.join(TEST_DIR, 'test_articles', filename)
def load_article(file_name):
"""Helper to fetch in the content of a test article."""
file_path = join(TEST_DIR, "data/articles", file_name)
with open(file_path) as file:
return file.read()