简体   繁体   中英

Visual Studio 2019 does not find python tests (pytest or unittest)

I just started a Django project with Visual Studio 2019 ( v 16.4.3 ) to get familiar with it and I am seeing that the unit tests are not being discovered.

Visual Studio allows to add a unittest python file, that contains a file that should fail when run, so I am pretty sure that it should be discoverable:

import unittest

class Test_test_1(unittest.TestCase):
    def test_A(self):
        self.fail("Not implemented")

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

I also tried to change the settings in Project/Properties and tried with both pytest and unittest, but the result is the same:

在此处输入图片说明 (of course clicking "Run All" doesn't discover anything)

Running python manage.py test finds 0 tests as well:

在此处输入图片说明

Is it a known Visual Studio problem?
Or am I placing the files in the wrong path?
Any hint about what I am doing wrong here?

ps I saw another question on SO about this, but this guy was getting an error. I just get nothing at all.

Oddly enough, reopening Visual Studio after having installed PyCharm prompted a message about pytest not being installed in the system (it was installed, I am sure of it). Clicking on the action in the message reinstalled it and, after rebuilding the project, the tests were discovered:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM