Dorthu / openapi3

A Python3 OpenAPI 3 Spec Parser
BSD 3-Clause "New" or "Revised" License
118 stars 47 forks source link

Testing doesn't work #72

Closed smurfix closed 2 years ago

smurfix commented 2 years ago
$ PYTHONPATH=. python3 -mpytest -sxv tests/

Test session starts (platform: linux, Python 3.9.9, pytest 6.0.2, pytest-sugar 0.9.4)
cachedir: .pytest_cache
rootdir: /src/openapi3
plugins: asyncio-0.14.0, xdist-2.2.0, gc-0.0.1, sugar-0.9.4, cov-2.10.1, anyio-3.3.0.1, forked-1.3.0, mock-1.10.4
collecting ... 

――――――――――――――――――――――――――――――――――― ERROR at setup of test_createPet ――――――――――――――――――――――――――――――――――――
ScopeMismatch: You tried to access the 'function' scoped fixture 'unused_tcp_port_factory' with a 'session' scoped request object, involved factories
tests/fastapi_test.py:30:  def server(event_loop, config)
tests/fastapi_test.py:17:  def config(unused_tcp_port_factory)
../../usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:225:  def unused_tcp_port_factory()
                                                                                            4% ▍         
======================================== short test summary info ========================================
FAILED tests/fastapi_test.py::test_createPet
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Results (0.22s):
       1 error
Dorthu commented 2 years ago

That fixture if provided by pytest-asyncio, which is listed in the tests_require here. How were you installing test dependencies?

smurfix commented 2 years ago

Apparently it's version dependent. Doesn't work with 0.14, works with 0.16, stops working with 0.18.1:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/lib/python3/dist-packages/_pytest/main.py", line 236, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 911, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 308, in call_historic
INTERNALERROR>     res = self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/usr/lib/python3/dist-packages/pytest_asyncio/plugin.py", line 191, in pytest_configure
INTERNALERROR>     config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)
INTERNALERROR> AttributeError: 'Config' object has no attribute 'issue_config_time_warning'
Dorthu commented 2 years ago

Opened #76 to pin the dependency to 0.16 - will look into why only that specific version works in the future.