Ho una classe di test per testare i miei metodi ma ho qualche problema con il passaggio di sé, entrambi sono all'interno della classe e della classe di test.metodi di classe chiamata pytest test class, l'errore di tipo richiede esattamente 2 argomenti (1 dato)
il mio metodo:
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')
mio banco di prova:
@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()]))
errore:
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
...
realtà; stai usando [naso] (https://nose.readthedocs.org/en/latest/) o pytest? Il titolo della domanda implica [pytest] (https://pytest.org) - Anche il tuo tag include '' pytest''. -- Cos'è questo? –
@James Mills Sto usando pytest ma sto provando ad usare il nose parametrizzato con esso. –
No; usa la parametrizzazione e le attrezzature di pytest :) Per favore! Non complicare le cose con due framework di test! –