mockafka-py icon indicating copy to clipboard operation
mockafka-py copied to clipboard

Basic use case examples not working: `fixture 'message' not found`

Open th0ger opened this issue 1 year ago • 2 comments

Describe the bug Following the basic use cases in the README does not work. pytest returns fixture 'message' not found. Tested with poetry and pip.

To Reproduce

poetry init
poetry add mockafka-py
poetry shell
### test.py ###
from mockafka import produce, consume

@produce(topic='test', key='test_key', value='test_value', partition=4)
@consume(topics=['test'])
def test_produce_and_consume_decorator(message):
    """
    This test showcases the usage of both @produce and @consume decorators in a single test case.
    It produces a message to the 'test' topic and then consumes it to perform further logic.
    # Notice you may get message None
    """
    # Your test logic for processing the consumed message here

    if not message:
        return

    pass
$ pytest test.py

=================================================================================================================================================== test session starts ====================================================================================================================================================
platform linux -- Python 3.11.6, pytest-8.3.3, pluggy-1.5.0
rootdir: 
configfile: pyproject.toml
plugins: asyncio-0.23.8, cov-5.0.0
asyncio: mode=Mode.STRICT
collected 1 item

test.py E                                                                                                                                                                                                                                                                                                            [100%]

========================================================================================================================================================== ERRORS ==========================================================================================================================================================
___________________________________________________________________________________________________________________________________ ERROR at setup of test_produce_and_consume_decorator ___________________________________________________________________________________________________________________________________
file test.py, line 4
  @produce(topic='test', key='test_key', value='test_value', partition=4)
  @consume(topics=['test'])
  def test_produce_and_consume_decorator(message):
E       fixture 'message' not found
>       available fixtures: _session_event_loop, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, event_loop, event_loop_policy, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, test.py::<event_loop>, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory, unused_tcp_port, unused_tcp_port_factory, unused_udp_port, unused_udp_port_factory
>       use 'pytest --fixtures [testpath]' for help on them.

Expected behavior Test passes successfully.

Desktop (please complete the following information):

  • OS: Ubuntu 23.10
  • python version 3.11.6
  • mockafka-py: 0.1.61

th0ger avatar Nov 04 '24 10:11 th0ger