1

Summary: After moving a file with a TestCase class in it (using refactor), tests are no longer executed at all.

I have a class startupTests.py that has:

import unittest
import logging
logging.basicConfig(level=logging.ERROR)

if __name__ == '__main__':
    unittest.main()

in it. I have a testcase class on the same level with multiple test. In the past I could simply run this startupTests.py class to execute all tests (including tests in other files on the same level). Here is another example file test_example.py with tests that were executed when I called startupTests.py

from unittest import TestCase


class TestValidateConfiguration(TestCase):
    def test_example(self):
        self.assertTrue(True)

I knew that I would write quite a few tests, so I decided to move test_example.py into another folder. I noticed that this somehow broke the connection between startupTests.py and test_example.py. The TestCases in startupTests.py were no longer executed when running startupTest.py

I can still execute the tests in test_example.py using the green arrow next to the code in the GUI. But they are no longer executed when running startupTests.py. I would like to - again - execute all tests in all test_files when running my main in startupTests.py

What I have tried

  1. I moved the file back into the same folder, but still they are not executed. Therefore it is not the "you need an init.py file to discover" problem.
  2. I created a second file with a TestCase, in order to see if the connection was just broken to the old file. Tests in the new file are also not executed.
  3. I explicitly set PythonIntegratedTools>Testing>Default test runner to Unittests
  4. I looked for visual changes in the code, but found none.
2
  • 1
    "I can still execute the tests using the GUI." So what kinds of tests are not working? Tests on the command line? Commented Mar 31, 2022 at 16:54
  • Thank you for your comment. I see that my issue was very implicit. I updated the question in order to make both the different files and my current issue more clear. Commented Mar 31, 2022 at 17:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.