forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Milestone
Description
Refs: #16962
- macOS @jrieken
- linux @connor4312
- macOS @chrisdias (Optional)
- windows @rzhao271
Complexity: 3
Requirements
- You will need two versions of python for this 3.* and 2.7.
- You can either install from python.org
OR - You can use
pyenvmac/linux orpyenv-winwindows. Then usepyenv install 3.9.4 2.7.18to get the two verisons.
- You can either install from python.org
- Install python extension from here: https://pvsc.blob.core.windows.net/extension-builds/ms-python-insiders.vsix
- Make sure you have
"python.experiments.optInto": ["All"],in your user settings. If you did not have it, add it and reload.
Testing
- Open an empty folder in VS Code.
- Add following code to a file named
test_example.py:
import unittest
class PassingTests(unittest.TestCase):
def test_passing(self):
self.assertEqual(42, 42)
def test_passing_still(self):
self.assertEqual("silly walk", "silly walk")
class FailingTests(unittest.TestCase):
def test_failure(self):
self.assertEqual(42, -13)
def test_failure_still(self):
self.assertEqual("I'm right!", "no, I am!")- Start with python version 3.*.
- You can either configure tests using
Python: configure tests...command from the command pallet, or go the test view and configure by using the welcome view, or you can run tests to get a prompt to configure. - Select
unittestframework. - You should see the tests in the test view. Run the tests.
- Now change python version to python 2.7, it should automatically refresh and allow you to run tests with python 2.7
Reactions are currently unavailable