Skip to content

Testing - Changing from 3.* python to 2.7  #17055

Closed

Description

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

Activity

  1. jrieken commented on Aug 24, 2021

    @jrieken

    Kind of blocked because test discovery doesn't work for me

  2. karthiknadig commented on Aug 24, 2021

    @karthiknadig
    MemberAuthor

    Johannes Rieken (@jrieken) Can you elaborate on where you are stuck?

    If you have the test file in the root of the project then your settings should look like this:

    {
        "python.testing.unittestArgs": [
            "-v",
            "-s",
            ".",
            "-p",
            "*test*.py"
        ],
        "python.testing.pytestEnabled": false,
        "python.testing.unittestEnabled": true
    }
    

    If your test file is in a sub-directory (say mytests) then it should look like this:

    {
        "python.testing.unittestArgs": [
            "-v",
            "-s",
            "./mytests",
            "-p",
            "test_*.py"
        ],
        "python.testing.pytestEnabled": false,
        "python.testing.unittestEnabled": true
    }
    

    Can you share how the settings looks like?

  3. jrieken commented on Aug 24, 2021

    @jrieken

    This issue #17092. Please update the test item so that this can be tested without python skills

  4. brettcannon commented on Aug 24, 2021

    @brettcannon
    Member

    Johannes Rieken (@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?

  5. rzhao271 commented on Aug 24, 2021

    @rzhao271

    Specifying the file name to use helped a lot, because

    1. I've ran into the issue of accidentally overriding a module before while testing out a Python feature
    2. It corresponds to one of the entries in the quick pick while running the configure command.
  6. jrieken commented on Aug 25, 2021

    @jrieken

    Still, not working for me

    Screen.Recording.2021-08-25.at.09.59.16.mov
  7. karthiknadig commented on Aug 25, 2021

    @karthiknadig
    MemberAuthor

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

  8. sandy081 commented on Aug 26, 2021

    @sandy081
    Member

    Chris Dias (@chrisdias) A friendly reminder to test this Test Plan Item. Since it is optional and if are busy with other stuff please let me know so that I can close this. Thanks.

  9. chrisdias commented on Aug 26, 2021

    @chrisdias

    Sorry, I tested this. LGTM, I had similar feedback to Johannes Rieken (@jrieken) but it basically worked.

  10. locked as resolved and limited conversation to collaborators on Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions