question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing - Changing from 3.* python to 2.7

See original GitHub issue

Refs: #16962

Complexity: 3

Create Issue


Requirements

  1. You will need two versions of python for this 3.* and 2.7.
    1. You can either install from python.org OR
    2. You can use pyenv mac/linux or pyenv-win windows. Then use pyenv install 3.9.4 2.7.18 to get the two verisons.
  2. Install python extension from here: https://pvsc.blob.core.windows.net/extension-builds/ms-python-insiders.vsix
  3. Make sure you have "python.experiments.optInto": ["All"], in your user settings. If you did not have it, add it and reload.

Testing

  1. Open an empty folder in VS Code.
  2. 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!")
  1. Start with python version 3.*.
  2. 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.
  3. Select unittest framework.
  4. You should see the tests in the test view. Run the tests.
  5. Now change python version to python 2.7, it should automatically refresh and allow you to run tests with python 2.7

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
karthiknadigcommented, Aug 25, 2021

@jrieken You are not using the insider version of the extension. You should see only two options when you configure: image

1reaction
brettcannoncommented, Aug 24, 2021

@jrieken is it just the file name issue? The instructions originally had a file name suggestion, but I just updated them to flat-out specify a file name. Otherwise is there something else you consider too ambiguous for non-Python users?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Porting Python 2 Code to Python 3 — Python 3.11.1 ...
Once you have your code well-tested you are ready to begin porting your code to Python 3! But to fully understand how your...
Read more >
Python 2.7 to 3.X Migration Guide - STX Next
Review the changes. They should be reasonably safe, but sometimes visibly inefficient—adjust them as you see fit. Test your app on Python 2....
Read more >
Python 2 to 3 Migration: A Developer's Experience - ActiveState
Your Python 2 to 3 migration strategy will depend on a number of factors. This post provides guidelines and tools to ease the...
Read more >
How to Update Python 2 to Python 3 - The Couchbase Blog
As part of the Python upgrade process, we have identified the major changes needed to successfully port to version 3. Some of the...
Read more >
The key differences between Python 2.7.x and Python 3.x with ...
The print function #. Very trivial, and the change in the print-syntax is probably the most widely known change, but still it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found