pytest-dev / pytest-random-order

pytest plugin to randomise the order of tests with some control over the randomness
MIT License
65 stars 10 forks source link

Get following error after installing the plugins, seems to be caused by version compatibility #39

Closed hdw868 closed 5 years ago

hdw868 commented 5 years ago

tjust run pytest will call following error: ============================= test session starts ============================= platform win32 -- Python 2.7.14, pytest-4.1.0, py-1.6.0, pluggy-0.7.1 -- c:\python27\python.exe cachedir: .pytest_cache Using --random-order-bucket=module Using --random-order-seed=571428

metadata: {'Python': '2.7.14', 'Platform': 'Windows-10-10.0.16299', 'Packages': {'py': '1.6.0', 'pytest': '4.1.0', 'pluggy': '0.7.1'}, 'JAVA_HOME': 'C:\Program Files\Java\jdk1.8.0_181', 'Plugins': {'bdd': '3.0.1', 'repeat': '0.7.0', 'datadir': '1.2.1', 'xdist': '1.25.0', 'random-order': '0.8.0', 'json': '0.4.0', 'html': '1.20.0', 'forked': '0.2', 'regressions': '1.0.5', 'metadata': '1.8.0'}} rootdir: E:\Dev\test_mstr_rest\tests, inifile: pytest.ini plugins: xdist-1.25.0, repeat-0.7.0, regressions-1.0.5, random-order-0.8.0, metadata-1.8.0, json-0.4.0, html-1.20.0, forked-0.2, datadir-1.2.1, bdd-3.0.1 collecting ... INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "c:\python27\lib\site-packages_pytest\main.py", line 203, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "c:\python27\lib\site-packages_pytest\main.py", line 242, in _main INTERNALERROR> config.hook.pytest_collection(session=session) INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\hooks.py", line 258, in call INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\manager.py", line 67, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\manager.py", line 61, in INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'), INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\callers.py", line 201, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\callers.py", line 77, in get_result INTERNALERROR> _reraise(ex) # noqa INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\callers.py", line 180, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "c:\python27\lib\site-packages_pytest\main.py", line 252, in pytest_collection INTERNALERROR> return session.perform_collect() INTERNALERROR> File "c:\python27\lib\site-packages_pytest\main.py", line 468, in perform_collect INTERNALERROR> session=self, config=self.config, items=items INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\hooks.py", line 258, in call INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\manager.py", line 67, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\manager.py", line 61, in INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'), INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\callers.py", line 201, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\callers.py", line 77, in get_result INTERNALERROR> _reraise(ex) # noqa INTERNALERROR> File "c:\python27\lib\site-packages\pluggy\callers.py", line 180, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "c:\python27\lib\site-packages\pytest_random_order\plugin.py", line 74, in pytest_collection_modifyitems INTERNALERROR> config.warn(0, failure, None) INTERNALERROR> AttributeError: 'Config' object has no attribute 'warn'

hdw868 commented 5 years ago

API changed since pytest 4.0, the fix will be simply change config.warn to Warning.warn according to https://docs.pytest.org/en/latest/deprecations.html#config-warn-and-node-warn

jbasko commented 5 years ago

You're on an old pytest version - 0.8.0 which isn't ready for pytest 4.0. I fixed pytest 4.0 compatibility in 1.0.3. The latest version is 1.0.4 https://pypi.org/project/pytest-random-order/ However, it won't work with Python 2.7 (pytest-random-order 1.0+ is for Python 3.5+ only) so I'm afraid you're out of luck here. I don't plan to support Python 2.7 again.

hdw868 commented 5 years ago

You're on an old pytest version - 0.8.0 which isn't ready for pytest 4.0. I fixed pytest 4.0 compatibility in 1.0.3. The latest version is 1.0.4 https://pypi.org/project/pytest-random-order/ However, it won't work with Python 2.7 (pytest-random-order 1.0+ is for Python 3.5+ only) so I'm afraid you're out of luck here. I don't plan to support Python 2.7 again.

Thanks for your quick response,I will update to the latest version and try again.