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

Got SystemExit when run an unittest without debug. #1529

Closed
weqopy opened this issue Apr 27, 2018 · 11 comments · Fixed by #1597
Closed

Got SystemExit when run an unittest without debug. #1529

weqopy opened this issue Apr 27, 2018 · 11 comments · Fixed by #1597
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@weqopy
Copy link

weqopy commented Apr 27, 2018

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
@weqopy
Copy link
Author

weqopy commented Apr 27, 2018

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.

@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug needs verification area-testing labels Apr 27, 2018
@brettcannon
Copy link
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.

@brettcannon brettcannon added info-needed Issue requires more information from poster and removed needs verification labels Apr 27, 2018
@weqopy
Copy link
Author

weqopy commented Apr 28, 2018

@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

@brettcannon brettcannon added needs verification and removed info-needed Issue requires more information from poster labels Apr 30, 2018
@brettcannon
Copy link
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?

@brettcannon brettcannon added info-needed Issue requires more information from poster and removed needs verification labels Apr 30, 2018
@weqopy
Copy link
Author

weqopy commented May 1, 2018

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.

@brettcannon
Copy link
Member

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

@weqopy
Copy link
Author

weqopy commented May 2, 2018

image
@brettcannon It still OK.

@brettcannon
Copy link
Member

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

@weqopy
Copy link
Author

weqopy commented May 2, 2018

@brettcannon Sorry, this time is in correct way.
image

@brettcannon brettcannon added needs verification and removed info-needed Issue requires more information from poster labels May 3, 2018
@brettcannon
Copy link
Member

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

@DonJayamanne
Copy link

I'll have a look at this today.

@DonJayamanne DonJayamanne self-assigned this May 3, 2018
@brettcannon brettcannon added this to the May 2018 milestone May 3, 2018
DonJayamanne added a commit that referenced this issue May 7, 2018
* Close communication channel before exiting the test runner
* revert change
* Fixes #1529
@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants