Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
karthiknadig opened this issue Aug 20, 2021 · 9 comments
Closed
4 tasks done

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

karthiknadig opened this issue Aug 20, 2021 · 9 comments

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Aug 20, 2021

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
@karthiknadig karthiknadig added this to the August 2021 milestone Aug 20, 2021
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Aug 20, 2021
@karthiknadig karthiknadig removed the triage-needed Needs assignment to the proper sub-team label Aug 20, 2021
@jrieken
Copy link
Member

jrieken commented Aug 24, 2021

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

@karthiknadig
Copy link
Member Author

@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?

@jrieken
Copy link
Member

jrieken commented Aug 24, 2021

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

@brettcannon
Copy link
Member

@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?

@rzhao271 rzhao271 assigned rzhao271 and unassigned tanhakabir Aug 24, 2021
@rzhao271
Copy link

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.

@rzhao271 rzhao271 removed their assignment Aug 24, 2021
@jrieken
Copy link
Member

jrieken commented Aug 25, 2021

Still, not working for me

Screen.Recording.2021-08-25.at.09.59.16.mov

@karthiknadig
Copy link
Member Author

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

@connor4312 connor4312 removed their assignment Aug 25, 2021
@jrieken jrieken removed their assignment Aug 26, 2021
@sandy081
Copy link
Member

@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.

@chrisdias chrisdias removed their assignment Aug 26, 2021
@chrisdias
Copy link
Member

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants