Using nosetests in PyCharm having python 2 and 3 installed side by side

I am trying to use nosetest with python 2 and 3 isntalled side by side in PyCharm (2.7.3).

Everything works fine under python 2.7, but any test in python 3.4 does not work with the following error:

Traceback (most recent call last): File "/home/robert/Programme/pycharm-2.7.3/helpers/pycharm/noserunner.py", line 91, in <module> process_args() File "/home/robert/Programme/pycharm-2.7.3/helpers/pycharm/noserunner.py", line 88, in process_args TestProgram(argv=argv, config=config) File "/usr/local/lib/python3.4/dist-packages/nose/core.py", line 121, in __init__ **extra_args) File "/usr/lib/python3.4/unittest/main.py", line 93, in __init__ self.runTests() File "/usr/local/lib/python3.4/dist-packages/nose/core.py", line 207, in runTests result = self.testRunner.run(self.test) File "/usr/local/lib/python3.4/dist-packages/nose/core.py", line 62, in run test(result) File "/usr/local/lib/python3.4/dist-packages/nose/suite.py", line 177, in __call__ return self.run(*arg, **kw) File "/usr/local/lib/python3.4/dist-packages/nose/suite.py", line 224, in run test(orig) File "/usr/local/lib/python3.4/dist-packages/nose/suite.py", line 177, in __call__ return self.run(*arg, **kw) File "/usr/local/lib/python3.4/dist-packages/nose/suite.py", line 224, in run test(orig) File "/usr/local/lib/python3.4/dist-packages/nose/case.py", line 46, in __call__ return self.run(*arg, **kwarg) File "/usr/local/lib/python3.4/dist-packages/nose/case.py", line 139, in run result.addError(self, err) File "/usr/local/lib/python3.4/dist-packages/nose/proxy.py", line 131, in addError plugins.addError(self.test, err) File "/usr/local/lib/python3.4/dist-packages/nose/plugins/manager.py", line 99, in __call__ return self.call(*arg, **kw) File "/usr/local/lib/python3.4/dist-packages/nose/plugins/manager.py", line 167, in simple result = meth(*arg, **kw) File "/home/robert/Programme/pycharm-2.7.3/helpers/pycharm/nose_utils.py", line 51, in addError err = self.formatErr(err) File "/home/robert/Programme/pycharm-2.7.3/helpers/pycharm/nose_utils.py", line 58, in formatErr return ''.join(traceback.format_exception(exctype, value, tb)) File "/usr/lib/python3.4/traceback.py", line 181, in format_exception return list(_format_exception_iter(etype, value, tb, limit, chain)) File "/usr/lib/python3.4/traceback.py", line 146, in _format_exception_iter for value, tb in values: File "/usr/lib/python3.4/traceback.py", line 125, in _iter_chain context = exc.__context__ AttributeError: 'str' object has no attribute '__context__' 

Also, in the nosetest run run configuration for python 3 interpreter, it says:

 WARNING: No nosetest runner found in selected interpreter 

What do I need to do to fix this? How to choose a suitable runner for python 3 nosetests in pyCharm (2.7.3)? Thanks!

EDIT: Btw, it pyCharm 2.7.3

+7
pycharm nose nosetests
source share
1 answer

Good to post my workaround here so that it is easier to find for others. Replacing line 58 in PathToPyCharm/pycharm-2.7.3/helpers/pycharm/nose_utils.py with

 if sys.version_info[0]==3: return ''.join(traceback.format_exception(exctype, value, tb, chain=False)) else: return ''.join(traceback.format_exception(exctype, value, tb)) 

did nosetests work with python 3.4 and 2.7. However, using python 3.4, the entire stack trace is lost if an error occurs. As a result, debugging becomes a nightmare: (

Finally, I solved the problem simply by upgrading my version of PyCharm to 3.4.1.

+7
source share

All Articles