0

I have noticed that when using Python's unittest.TestCase unit testing package, PyCharm's Unit Testing tool is able to recognize the tests when the files are named anything other than __init__.py. However, when I name them __init__.py, PyCharm doesn't pick them up. This is the error I get:

ImportError: '__init__' module incorrectly imported from 'C:\\Users\\morrij14\\AppData\\Roaming\\JetBrains\\PyCharm Community Edition 2017.1.2\\helpers\\pycharm'. Expected 'C:\\Users\\morrij14\\ivy\\Unit_Test3\\lib\\pt_hil\\utilities\\PT_HIL_Report_Utils\\html_utility\\tests'. Is this module globally installed?

I am guessing it has to be something with the PyCharm settings. Or maybe Unit Test files are not supposed to be named init.py

Slaknation
  • 2,124
  • 3
  • 23
  • 42
  • You might want to take a look at this question to learn more about `__init__.py`: https://stackoverflow.com/questions/448271/what-is-init-py-for – kenfire Aug 31 '17 at 14:25
  • Code inside of `__init__.py` can run, but IDEs do not parse them, and that's not what dunder init is meant for. If you put actual code into your dunder init, you are going to have a bad time. – nanotek Aug 31 '17 at 15:44

0 Answers0