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

Docstrings in test functions confuse unittest's output parser #129

Closed
Korbz opened this issue Nov 6, 2019 · 3 comments · Fixed by #134
Closed

Docstrings in test functions confuse unittest's output parser #129

Korbz opened this issue Nov 6, 2019 · 3 comments · Fixed by #134
Labels
Milestone

Comments

@Korbz
Copy link

Korbz commented Nov 6, 2019

Description

What steps will reproduce the problem?

Started a unit test case with unittest

Unit Test class:

import unittest
from src import add

class AddTestCase(unittest.TestCase):

    def test_add(self):
        """Is five successfully determined to be prime?"""
        addition = add.add(2,3)
        self.assertEquals(5, addition)

if __name__ == '__main__':
    unittest.main()

Tested function:

def add(x, y):
    return x+y

Traceback

  File "C:\Users\acorbi\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_unittest\widgets\unittestgui.py", line 342, in tests_started
    self.testdatamodel.update_testresults(testresults)
  File "C:\Users\acorbi\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_unittest\widgets\datatree.py", line 265, in update_testresults
    raise KeyError('test not found')
KeyError: 'test not found'
Traceback (most recent call last):
  File "C:\Users\acorbi\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_unittest\widgets\unittestgui.py", line 354, in tests_yield_result
    self.testdatamodel.update_testresults(testresults)
  File "C:\Users\acorbi\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_unittest\widgets\datatree.py", line 265, in update_testresults
    raise KeyError('test not found')
KeyError: 'test not found'

Versions

  • Spyder version: 3.3.6
  • Python version: 3.7.4
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Windows 10

Dependencies

pyflakes >=0.6.0  :  2.1.1 (OK)
pycodestyle >=2.3 :  2.5.0 (OK)
pygments >=2.0    :  2.4.2 (OK)
sphinx >=0.6.6    :  2.2.0 (OK)
rope >=0.9.4      :  0.14.0 (OK)
jedi >=0.9.0      :  0.15.1 (OK)
nbconvert >=4.0   :  5.6.0 (OK)
pandas >=0.13.1   :  0.25.1 (OK)
numpy >=1.7       :  1.16.5 (OK)
sympy >=0.7.3     :  1.4 (OK)
cython >=0.21     :  0.29.13 (OK)
qtconsole >=4.2.0 :  4.5.5 (OK)
IPython >=4.0     :  7.8.0 (OK)
matplotlib >=2.0.0:  3.1.1 (OK)
pylint >=0.25     :  2.4.2 (OK)
@Korbz Korbz changed the title Crash during unittest Internal error during unittest Nov 6, 2019
@ccordoba12 ccordoba12 transferred this issue from spyder-ide/spyder Nov 6, 2019
@jitseniesen
Copy link
Member

@Korbz What version of the spyder-unittest plugin are you using? A very similar issue was fixed in version 0.3.0, so maybe uprading the plugin will fix this for you.

@Korbz
Copy link
Author

Korbz commented Nov 7, 2019

@Korbz What version of the spyder-unittest plugin are you using? A very similar issue was fixed in version 0.3.0, so maybe uprading the plugin will fix this for you.

I'm using version 0.3.1.
Switching the test framework to nose solved this issue.

@jitseniesen
Copy link
Member

I can reproduce this, except that Spyder hangs on my computer. I think it has to do with the docstring in the test function. Unittest prints out this docstring and that confuses the parser. I will try to fix this.

Thanks for the report.

@jitseniesen jitseniesen added this to the v0.4 milestone Nov 8, 2019
@jitseniesen jitseniesen changed the title Internal error during unittest Docstrings in test functions confuse unittest's output parser Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants