You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Got SystemExit when run an unittest without debug. #1529
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()
run this in debug mode, it's okey
.
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
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
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.
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.
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?
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.
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.
Activity
weqopy commentedon 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.pyis where I installed python by Homebrew.brettcannon commentedon Apr 27, 2018
Are you sure you have the appropriate paths to your virtual environment set in the extension? If you have it specified differently in
launch.jsoncompared tosettings.jsonthat would explain the difference.weqopy commentedon Apr 28, 2018
Brett Cannon (@brettcannon)
I have checked that the path is not different between
launch.jsonandsettings.json.launch.json:"pythonPath": "${config:python.pythonPath}",and
settings.json:"python.pythonPath": "~/venv/bin/python",And after I delete
pythonPathfromlaunch.json, it still shows the sameSystemExitbrettcannon commentedon Apr 30, 2018
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?
weqopy commentedon May 1, 2018
No, it's OK in terminal.

Luckily it's just a little problem and I think we can ignore it at now.
brettcannon commentedon May 1, 2018
Fly (@weqopy) what happens if you go through
python -m unittestto execute the files? That's the more interesting case as that's how we execute your code.weqopy commentedon May 2, 2018
Brett Cannon (@brettcannon) It still OK.
brettcannon commentedon May 2, 2018
Fly (@weqopy) notice that no tests were run. You need to either use
unittest discoveror tell unittest to actually run your test file.weqopy commentedon May 2, 2018
Brett Cannon (@brettcannon) Sorry, this time is in correct way.

brettcannon commentedon May 3, 2018
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.
DonJayamanne commentedon May 3, 2018
I'll have a look at this today.
Close communication channel before exiting the test runner (#1597)