This project has moved and is read-only. For the latest updates, please go here.


Unittest features don't work with VS2013 desktop and PTVS 2.1RC


  1. Create a new project using File - > New Project and select "Python Application"
  2. Add a new file to the project and select "Python Unit Test"
  3. Go to Test -> Windows and select "Test Explorer"
  4. Note that it takes over 10 seconds to find the test in this tiny project.
  5. Go to the task manager and note that vstest.discoveryengine.x86.exe grows very quickly to 90MB
  6. Click the "Run all tests" button and note that the test output window shows the following and just sits there (I waited 20 minutes last night before killing it):
------ Run test started ------
Note that a second vstest.discoveryengine.x86.exe process launches when hitting the run all button.

Now that I am trying to re-produce this methodically I can't re-create the behavior I saw yesterday where the vstest.discoveryengine.x86.exe process grew to over 1.5GB. However it is very reproducible that the tests don't run and the discovery process takes way longer than I would expect for a small and simple process.

Version details in attachment. Python is Canopy 1.4.1 32 bit

If you replace the test module code with the code below (just me messing around with the various unittest features) and then mess around with re-saving the file and starting/stopping test runs the vstest.discoveryengine.x86.exe grows to 210MB. Continuing to mess around in this setting might cause the memory leak type behavior I saw previously
import unittest

class Test_test1(unittest.TestCase):
    def test_A(self):
    def test_B(self):
    @unittest.skipIf(True,"Not needed")
    def test_C(self):
        self.assertTrue(True,"A reason why")

if __name__ == '__main__':
    log_file = 'log_file.txt'
    f = open(log_file, "w")
    runner = unittest.TextTestRunner(f)
    unittest.main(testRunner=runner, exit=False, verbosity=2)
    suite = unittest.TestLoader().discover(start_dir = ".",pattern="test*.py")
    f = open(log_file, "w")
    t = unittest.TextTestRunner(verbosity=2).run(suite)
    print t.wasSuccessful()

file attachments


Zooba wrote Aug 29, 2014 at 10:29 PM

So a major part of the memory usage and delay is due to loading the cached completion DB from disk. Canopy is a very large distribution (as you no doubt noticed while it was analyzing) and so it takes a noticeable amount of time to load it.

I may have also discovered the source of the leak (I mentioned that the code is largely shared with VS, so I checked the few parts that aren't shared...) and we may be leaking threads as well as memory :( I'm investigating further.

Zooba wrote Sep 4, 2014 at 12:25 AM

I know there was more to this issue than the memory leak, but it's not in the description here and I've fixed the leak, so marking this as resolved.

Feel free to file a separate issue or keep going on the other discussion thread until we figure out the rest.