-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
Description
In Python 2.7, test cases using the @responses.activate decorator die with an IOError in inspect.getsourcelines (added in v2.4.0).
These tests work with earlier releases; the problem still exists in v2.5.1 (latest as of this report).
I'm guessing this is similar to (but not fixed by) #187.
To reproduce
$ python --version
Python 2.7.16
$ pip install unittest-xml-reporting==2.5.1 requests responses mocktests.py:
import unittest
import xmlrunner
import responses
class DecoratedTests(unittest.TestCase):
@responses.activate
def test_responses(self):
self.assertEqual(1 + 1, 2)
if __name__ == '__main__':
unittest.main(
testRunner=xmlrunner.XMLTestRunner(output='test-reports'),
failfast=False, buffer=False, catchbreak=False)Results
$ python tests.py
Running tests...
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 15, in <module>
failfast=False, buffer=False, catchbreak=False)
[... snip -- full stack trace included below]
File "...site-packages/xmlrunner/result.py", line 273, in startTest
_, self.lineno = inspect.getsourcelines(test_method)
[... snip]
File "...python2.7/inspect.py", line 537, in findsource
raise IOError('could not get source code')
IOError: could not get source codeExpected
No error. (Try repeating with pip install -U unittest-xml-reporting==2.3.2.)
More info
Full stack trace
Traceback (most recent call last):
File "tests.py", line 15, in <module>
failfast=False, buffer=False, catchbreak=False)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 232, in runTests
self.result = testRunner.run(self.test)
File "/Users/medmunds/.local/share/virtualenvs/xmlrunner-bug-xAnTk8wk/lib/python2.7/site-packages/xmlrunner/runner.py", line 70, in run
test(result)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 393, in __call__
return self.run(*args, **kwds)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 304, in run
result.startTest(self)
File "/Users/medmunds/.local/share/virtualenvs/xmlrunner-bug-xAnTk8wk/lib/python2.7/site-packages/xmlrunner/result.py", line 273, in startTest
_, self.lineno = inspect.getsourcelines(test_method)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 689, in getsourcelines
lines, lnum = findsource(object)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 537, in findsource
raise IOError('could not get source code')
IOError: could not get source code
pip list
Package Version
---------------------- --------
certifi 2019.3.9
chardet 3.0.4
cookies 2.2.1
funcsigs 1.0.2
idna 2.8
mock 2.0.0
pbr 5.1.3
pip 19.0.3
requests 2.21.0
responses 0.10.6
setuptools 41.0.0
six 1.12.0
unittest-xml-reporting 2.5.1
urllib3 1.24.1
wheel 0.33.1
rakesh-ridecell
Metadata
Metadata
Assignees
Labels
No labels