6

I have a Python 3.4 project that I'm working on using Visual Studio Code (v1.19.2)

The project structure is:

root
    foo
        __init__.py
        foo.py
        footests.py

footests.py contains my unittest based tests:

import unittest
import foo

class footests(unittest.TestCase):

    def test(self):
        self.assertEquals(True, True)

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

I have enabled unittest in my VS Code User Settings like so:

"python.unitTest.unittestEnabled": true,

My problem is that whenever I try to discover unit tests in VS Code, I get the following message:

No tests discovered, please check the configuration settings for the tests.

And in the VS Code Output window all I see is:

start

My question is - Why don't VS Code / unittest discover the unit test in the foo sub-folder?

urig
  • 16,016
  • 26
  • 115
  • 184
  • 1
    For me, when I replicate and run with a 3.4 venv, some errors appear the first time `Run All Unit Tests` is run but subsequent runs work. Problem must be more specific to your configuration. – Elliott Beach Jan 28 '18 at 19:30
  • @elliot-beach thanks. I tried a fresh repro based on my question and unit tests were recognized. I think maybe in my original project the `__pycache__` files became corrupted. – urig Jan 29 '18 at 18:35
  • You need to configure vscode to look for unit tests in the foo directory. Please check the following documentation to configure this https://code.visualstudio.com/docs/python/unit-testing#_unittest-configuration-settings – Don Feb 15 '18 at 05:39

0 Answers0