Skip to content

Got SystemExit when run an unittest without debug. #1529

Closed

Description

@weqopy

Environment data

  • VS Code version: 1.22.2
  • Extension version (available under the Extensions sidebar): 2018.3.1 (29 Mar 2018)
  • OS and version: macOS High Sierra 10.13.4
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.6.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: XXX

Actual behavior

Here is the unittest:

import unittest


class Solution:
    def powerSum(self, x, y):
        return x**2 + y**2


class testTmp(unittest.TestCase):
    def test_powerSum(self):
        tmp = Solution().powerSum(3, 4)
        self.assertEqual(tmp, 25)


if __name__ == '__main__':
    unittest.main()
  1. run this in debug mode, it's okey
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
  1. but when run it without debug
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Traceback (most recent call last):  File "/Users/***/Documents/pyfiles/tmp.py", line 19, in <module>
    unittest.main()
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/main.py", line 258, in runTests
    sys.exit(not self.result.wasSuccessful())
SystemExit: False

Activity

  1. weqopy commented on Apr 27, 2018

    @weqopy
    Author

    And there is another place which seems not correct.
    My virtual environment is virtualenv and it's path is ~/venv/bin/python.
    And in the 'Traceback', the path of /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/main.py is where I installed python by Homebrew.

  2. brettcannon commented on Apr 27, 2018

    @brettcannon
    Member

    Are you sure you have the appropriate paths to your virtual environment set in the extension? If you have it specified differently in launch.json compared to settings.json that would explain the difference.

  3. weqopy commented on Apr 28, 2018

    @weqopy
    Author

    Brett Cannon (@brettcannon)
    I have checked that the path is not different between launch.json and settings.json.

    launch.json: "pythonPath": "${config:python.pythonPath}",
    and settings.json: "python.pythonPath": "~/venv/bin/python",

    And after I delete pythonPath from launch.json, it still shows the same SystemExit

  4. brettcannon commented on Apr 30, 2018

    @brettcannon
    Member

    Unfortunately I can't replicate this at least on Windows 10 with Python 3.6.5. The other thing is that if you look at the traceback you will notice that none of our code is in it, so we don't seem to be influencing the running of it. Do you get the same error if you run the tests manually from the terminal?

  5. weqopy commented on May 1, 2018

    @weqopy
    Author

    No, it's OK in terminal.
    2018-05-01_17-44-06

    Luckily it's just a little problem and I think we can ignore it at now.

  6. brettcannon commented on May 1, 2018

    @brettcannon
    Member

    Fly (@weqopy) what happens if you go through python -m unittest to execute the files? That's the more interesting case as that's how we execute your code.

  7. weqopy commented on May 2, 2018

    @weqopy
    Author
  8. brettcannon commented on May 2, 2018

    @brettcannon
    Member

    Fly (@weqopy) notice that no tests were run. You need to either use unittest discover or tell unittest to actually run your test file.

  9. weqopy commented on May 2, 2018

    @weqopy
    Author

    Brett Cannon (@brettcannon) Sorry, this time is in correct way.
    image

  10. brettcannon commented on May 3, 2018

    @brettcannon
    Member

    Fly (@weqopy) I'm at a loss. We will give it one more try to reproduce.

    NOTE TO TEAM: If we can't we should turn this into an issue to add logging to the extension and then ask the OP to try the development build to see what's going on.

  11. DonJayamanne commented on May 3, 2018

    @DonJayamanne

    I'll have a look at this today.

  12. added a commit that references this issue on May 7, 2018
    b40cc2c
  13. locked as resolved and limited conversation to collaborators on Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions