mercredi 27 mai 2015

pytest test class calling class methods, Type error takes exactly 2 arguments (1 given)

I have a test class to test my methods but i have some issue with passing self, both of them are inside class and test class.

my method:

def get_all_links(self):
    """return all the links inside an html

    :return: list of links from an html page
    :rtype: list
    """
    return self.html.find_all('a')

my test case:

    @parameterized.expand(["http://www.google.com", "http://www.walla.com"])
    def test_get_all_links_known_links(self, known_link):
        """check get_all_links with a known link list

        :param known_link: lick to find
        :type known_link: str
        """
        html = Parser(open(os.path.normpath(os.path.join(self.root, "test.html"))))

        self.assertTrue(any([known_link in str(l) for l in html.get_all_links()]))

error:

E TypeError: test_get_all_links_known_links() takes exactly 2 arguments (1 given)

/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py:329: TypeError
...

Aucun commentaire:

Enregistrer un commentaire