M
M
Mnab2016-06-23 10:01:04
Python
Mnab, 2016-06-23 10:01:04

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()

What is cached somewhere?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mnab, 2016-06-24
@Mnab

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.

A
Alexey Cheremisin, 2016-06-23
@leahch

I suspect that there is no "recompilation" of pyc files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question