borntyping / python-riemann-client

A Riemann client and command line tool
http://riemann-client.readthedocs.io/en/latest/
MIT License
39 stars 12 forks source link

6.5.0: pytest needs `google` module #38

Closed kloczek closed 2 years ago

kloczek commented 3 years ago
+ /usr/bin/pytest -ra
ImportError while loading conftest '/home/tkloczko/rpmbuild/BUILD/riemann-client-6.5.0/tests/conftest.py'.
tests/conftest.py:7: in <module>
    import riemann_client.transport
riemann_client/transport.py:12: in <module>
    import riemann_client.riemann_pb2
riemann_client/riemann_pb2.py:8: in <module>
    from riemann_client.riemann_py3_pb2 import (Event, Msg, Query, Attribute)
riemann_client/riemann_py3_pb2.py:4: in <module>
    from google.protobuf import descriptor as _descriptor
E   ModuleNotFoundError: No module named 'google'

Howwever looks like it is not https://pypi.org/project/google/ so question is where it is that google module?

borntyping commented 3 years ago

It depends on the protobuf module - google is a namespace used by multiple packages from google.

https://github.com/borntyping/python-riemann-client/blob/master/setup.py#L8

kloczek commented 1 year ago

There is another issue after installing protobuf in build env

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-riemann-client-6.5.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-riemann-client-6.5.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
ImportError while loading conftest '/home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/tests/conftest.py'.
tests/conftest.py:5: in <module>
    import py.test
E   ModuleNotFoundError: No module named 'py.test'; 'py' is not a package

I think that instead py.test should be pytest 🤔

kloczek commented 1 year ago

After apply below patch

```patch --- a/tests/test_riemann_transport.py +++ b/tests/test_riemann_transport.py @@ -1,6 +1,6 @@ from __future__ import absolute_import -import py.test +import pytest import riemann_client.riemann_pb2 import riemann_client.transport @@ -24,13 +24,13 @@ assert socket_recvall(FakeSocket(), 5) == b'hello' -@py.test.fixture +@pytest.fixture def tcp_transport(): return riemann_client.transport.TCPTransport() def test_not_yet_connected(tcp_transport): - with py.test.raises(RuntimeError): + with pytest.raises(RuntimeError): tcp_transport.send(riemann_client.riemann_pb2.Msg()) --- a/tests/test_riemann_queued_client.py +++ b/tests/test_riemann_queued_client.py @@ -1,13 +1,13 @@ from __future__ import absolute_import -import py.test +import pytest import riemann_client.client import riemann_client.riemann_pb2 import riemann_client.transport -@py.test.fixture +@pytest.fixture def queued_client(request, string_transport): """A Riemann client using the StringIO transport and QueuedClient""" client = riemann_client.client.QueuedClient(transport=string_transport) @@ -20,13 +20,13 @@ return client -@py.test.fixture +@pytest.fixture def using_simple_queue(queued_client): """An event queue with a single event""" queued_client.event(service='test') -@py.test.fixture +@pytest.fixture def large_queue(queued_client): """An event queue with 100 events""" items = ['-->{0}<--'.format(i) for i in range(0, 1000)] --- a/tests/test_riemann_client.py +++ b/tests/test_riemann_client.py @@ -4,7 +4,7 @@ import sys import uuid -import py.test +import pytest import riemann_client.client import riemann_client.riemann_pb2 @@ -14,7 +14,7 @@ basestring = str -@py.test.fixture +@pytest.fixture def client(request, string_transport): client = riemann_client.client.Client(transport=string_transport) client.transport.connect() @@ -26,7 +26,7 @@ return client -@py.test.fixture +@pytest.fixture def unique(): return str(uuid.uuid4()) @@ -68,7 +68,7 @@ transport = riemann_client.transport.UDPTransport() client = riemann_client.client.Client(transport) - with py.test.raises(Exception): + with pytest.raises(Exception): client.query('true') def test_events(self, client): @@ -81,7 +81,7 @@ assert len(message.events) == 2 -@py.test.fixture +@pytest.fixture def event(unique): return riemann_client.client.Client.create_event({ 'host': 'test.example.com', @@ -104,7 +104,7 @@ assert event.attributes[0].value == unique -@py.test.fixture +@pytest.fixture def event_as_dict(event): return riemann_client.client.Client.create_dict(event) --- a/tests/test_riemann_auto_flushing_queued_client.py +++ b/tests/test_riemann_auto_flushing_queued_client.py @@ -1,6 +1,6 @@ from __future__ import absolute_import -import py.test +import pytest import socket import time @@ -9,7 +9,7 @@ import riemann_client.transport -@py.test.fixture +@pytest.fixture def blank_transport(): return riemann_client.transport.BlankTransport() @@ -25,12 +25,12 @@ raise socket.error(32, '[Errno 32] Broken pipe') -@py.test.fixture +@pytest.fixture def broken_transport(): return BrokenTransport() -@py.test.fixture +@pytest.fixture def auto_flushing_queued_client(request, blank_transport): """A Riemann client using the StringIO transport and AutoFlushingQueuedClient with max_delay=300 and @@ -49,7 +49,7 @@ return client -@py.test.fixture +@pytest.fixture def auto_flushing_queued_client_delay(request, blank_transport): """A Riemann client using the StringIO transport and AutoFlushingQueuedClient with max_delay=1 and @@ -68,7 +68,7 @@ return client -@py.test.fixture +@pytest.fixture def auto_flushing_queued_client_batch5(request, blank_transport): """A Riemann client using the StringIO transport and AutoFlushingQueuedClient with max_delay=300 and @@ -87,7 +87,7 @@ return client -@py.test.fixture +@pytest.fixture def auto_flushing_queued_client_batch5_broken_f(request, broken_transport): """A Riemann client using the StringIO transport and AutoFlushingQueuedClient with max_delay=300 and @@ -107,7 +107,7 @@ return client -@py.test.fixture +@pytest.fixture def auto_flushing_queued_client_batch5_broken_t(request, broken_transport): """A Riemann client using the StringIO transport and AutoFlushingQueuedClient with max_delay=300 and @@ -127,13 +127,13 @@ return client -@py.test.fixture +@pytest.fixture def using_simple_queue(auto_flushing_queued_client): """An event queue with a single event""" auto_flushing_queued_client.event(service='test') -@py.test.fixture +@pytest.fixture def large_queue(auto_flushing_queued_client): """An event queue with 100 events""" items = ['-->{0}<--'.format(i) for i in range(0, 1000)] --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,7 @@ import sys -import py.test +import pytest import riemann_client.transport @@ -25,6 +25,6 @@ self.string.close() -@py.test.fixture +@pytest.fixture def string_transport(): return StringTransport() --- a/tox.ini +++ b/tox.ini @@ -4,9 +4,9 @@ [testenv] commands= - test: py.test riemann_client tests + test: pytest riemann_client tests lint: flake8 --config tox.ini riemann_client tests - covr: coverage run --rcfile tox.ini --source riemann_client --module py.test + covr: coverage run --rcfile tox.ini --source riemann_client --module pytest covr: coverage report --rcfile tox.ini deps= test: pytest ```

and install click in build env now pytest shows

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-riemann-client-6.5.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-riemann-client-6.5.0-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ========================================================================================== ERRORS =========================================================================================== ______________________________________________________________________ ERROR collecting tests/test_riemann_command.py _______________________________________________________________________ /usr/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call result: Optional[TResult] = func() /usr/lib/python3.8/site-packages/_pytest/runner.py:372: in call = CallInfo.from_call(lambda: list(collector.collect()), "collect") /usr/lib/python3.8/site-packages/_pytest/python.py:536: in collect self._inject_setup_module_fixture() /usr/lib/python3.8/site-packages/_pytest/python.py:550: in _inject_setup_module_fixture self.obj, ("setUpModule", "setup_module") /usr/lib/python3.8/site-packages/_pytest/python.py:315: in obj self._obj = obj = self._getobj() /usr/lib/python3.8/site-packages/_pytest/python.py:533: in _getobj return self._importtestmodule() /usr/lib/python3.8/site-packages/_pytest/python.py:622: in _importtestmodule mod = import_path(self.path, mode=importmode, root=self.config.rootpath) /usr/lib/python3.8/site-packages/_pytest/pathlib.py:565: in import_path importlib.import_module(module_name) /usr/lib64/python3.8/importlib/__init__.py:127: in import_module return _bootstrap._gcd_import(name[level:], package, level) :1014: in _gcd_import ??? :991: in _find_and_load ??? :975: in _find_and_load_unlocked ??? :671: in _load_unlocked ??? /usr/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:178: in exec_module exec(co, module.__dict__) tests/test_riemann_command.py:8: in import riemann_client.command riemann_client/command.py:131: in def query(transport, query): /usr/lib/python3.8/site-packages/click/decorators.py:345: in decorator _param_memo(f, cls(param_decls, **attrs)) /usr/lib/python3.8/site-packages/click/core.py:2994: in __init__ super().__init__(param_decls, required=required, **attrs) /usr/lib/python3.8/site-packages/click/core.py:2111: in __init__ self.name, self.opts, self.secondary_opts = self._parse_decls( /usr/lib/python3.8/site-packages/click/core.py:3029: in _parse_decls raise TypeError( E TypeError: Arguments take exactly one parameter declaration, got 2. ===================================================================================== warnings summary ====================================================================================== ../../../../../usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1316 /usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1316: PytestRemovedIn8Warning: The --strict option is deprecated, use --strict-markers instead. self.issue_config_time_warning( riemann_client/riemann_py3_pb2.py:36 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:36: DeprecationWarning: Call to deprecated create function FileDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. DESCRIPTOR = _descriptor.FileDescriptor( riemann_client/riemann_py3_pb2.py:51 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:51: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:58 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:58: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:65 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:65: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:72 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:72: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:79 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:79: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:86 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:86: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:93 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:93: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:100 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:100: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:44 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:44: DeprecationWarning: Call to deprecated create function Descriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _STATE = _descriptor.Descriptor( riemann_client/riemann_py3_pb2.py:128 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:128: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:135 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:135: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:142 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:142: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:149 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:149: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:156 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:156: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:163 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:163: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:170 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:170: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:177 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:177: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:184 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:184: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:191 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:191: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:198 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:198: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:121 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:121: DeprecationWarning: Call to deprecated create function Descriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _EVENT = _descriptor.Descriptor( riemann_client/riemann_py3_pb2.py:226 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:226: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:219 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:219: DeprecationWarning: Call to deprecated create function Descriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _QUERY = _descriptor.Descriptor( riemann_client/riemann_py3_pb2.py:254 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:254: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:261 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:261: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:268 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:268: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:275 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:275: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:282 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:282: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:247 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:247: DeprecationWarning: Call to deprecated create function Descriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _MSG = _descriptor.Descriptor( riemann_client/riemann_py3_pb2.py:310 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:310: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:317 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:317: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _descriptor.FieldDescriptor( riemann_client/riemann_py3_pb2.py:303 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/riemann_client/riemann_py3_pb2.py:303: DeprecationWarning: Call to deprecated create function Descriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool. _ATTRIBUTE = _descriptor.Descriptor( tests/test_riemann_command.py:20 /home/tkloczko/rpmbuild/BUILD/python-riemann-client-6.5.0/tests/test_riemann_command.py:20: DeprecationWarning: invalid escape sequence \s return re.sub(u'\s+', u'', string) -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ================================================================================== short test summary info ================================================================================== ERROR tests/test_riemann_command.py - TypeError: Arguments take exactly one parameter declaration, got 2. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ```
borntyping commented 1 year ago

I belive pytest and click have made some breaking changes since this library was written, and it's not been updated to keep things compatible. I don't maintain this library any more — it's been almost a decade since I last used it.