Reputation: 9684
I am using pytest 5.4.1 with python 3.6
Code:
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
if __name__ == '__main__':
unittest.main()
Running pytest
gives the following error:
Testing started at 06:08 ...
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\python.exe" "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pycharm\_jb_pytest_runner.py" --path E:/Folder1/Project1/src/Project1.Api/tests/test1.py
Launching pytest with arguments E:/Folder1/Project1/src/Project1.Api/tests/test1.py in E:\Folder1\Project1\src\Project1.Api\tests
============================= test session starts =============================
platform win32 -- Python 3.6.5, pytest-5.4.1, py-1.5.3, pluggy-0.13.1 -- C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\python.exe
cachedir: .pytest_cache
rootdir: E:\Folder1\Project1\src\Project1.Api\tests
plugins: arraydiff-0.2, cov-2.8.1, doctestplus-0.1.3, openfiles-0.3.0, remotedata-0.2.1
collecting ... collected 1 item
test1.py::TestStringMethods::test_upper ERROR [100%]
test setup failed
item = <TestCaseFunction test_upper>
def pytest_runtest_setup(item):
> remote_data = item.get_marker('remote_data')
E AttributeError: 'TestCaseFunction' object has no attribute 'get_marker'
c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages\pytest_remotedata\plugin.py:59: AttributeError
Assertion failed
=================================== ERRORS ====================================
_______________ ERROR at setup of TestStringMethods.test_upper ________________
item = <TestCaseFunction test_upper>
def pytest_runtest_setup(item):
> remote_data = item.get_marker('remote_data')
E AttributeError: 'TestCaseFunction' object has no attribute 'get_marker'
c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages\pytest_remotedata\plugin.py:59: AttributeError
=========================== short test summary info ===========================
ERROR test1.py::TestStringMethods::test_upper - AttributeError: 'TestCaseFunc...
============================== 1 error in 0.04s ===============================
Process finished with exit code 0
Assertion failed
Assertion failed
What could be the issue?
Upvotes: 3
Views: 2114
Reputation: 69785
The problem is that get_marker
has been renamed get_closest_marker
. In this issue on GitHub, you can see that @arvindpdmn suggests upgrading pytest-remotedata==0.3.0
to pytest-remotedata==0.3.2
, so assuming you are using pip
for installing dependencies, run the following command:
pip install -U pytest-remotedata
Upvotes: 3
Reputation: 9684
As seen in the error output, the problem is in the pytest-remotedata package.
AttributeError: 'TestCaseFunction' object has no attribute 'get_marker'
c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages\pytest_remotedata\plugin.py:59: AttributeError
The error got resolved upon upgrading the pytest-remotedata
package to latest version (0.3.2):
pip install --upgrade pytest-remotedata
Upvotes: 1