Answer the question
In order to leave comments, you need to log in
Why does the test stop running when the method is renamed?
Good afternoon.
Tell me, when working with the unittest library, why, when renaming a method inside a class for tests, does this method not run as a separate test?
Environment: PyCharm CE
Example:
- there is a class with setUp(self), tearDown(self) methods and a couple of methods with tests. If this class is run through the menu 'Run unittests in FILE_NAME', then the tests are executed correctly. If one of the methods with the test is renamed, then this method as a test is no longer executed. However, if the method is renamed back to its previous form, then this method will again start running as a separate test.
import unittest
from selenium import webdriver
class FindingElems(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.get("http://google.com")
def test1(self):
self.search = self.driver.find_element_by_name("q")
self.search.send_keys("hello")
def test2(self):
self.search = self.driver.find_element_by_name("q")
self.search.send_keys("hello")
def tearDown(self):
self.driver.quit()
Answer the question
In order to leave comments, you need to log in
Figured it out on my own. The reason was that I renamed the method to a name that did not contain the word test, and the unittest library simply skips such methods and does not execute them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question