NicolasLM / spinach

Modern Redis task queue for Python 3
https://spinach.readthedocs.io
BSD 2-Clause "Simplified" License
63 stars 4 forks source link

Unit tests throw warnings #35

Closed 0xDEC0DE closed 6 months ago

0xDEC0DE commented 6 months ago

Steps to reproduce

tox

Expected result

Tests pass, no warnings

Actual behavior

tests/test_worker.py::test_can_accept_job[ThreadWorkers]
  /Users/nisimond/work/blastarea/spinach/.tox/py3/lib/python3.11/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread tests-worker-2

  Traceback (most recent call last):
    File "/Users/nisimond/work/blastarea/spinach/spinach/worker.py", line 118, in _worker_func
      job.task_func(*job.task_args, **job.task_kwargs)
      ^^^^^^^^^^^^^
  AttributeError: 'tuple' object has no attribute 'task_func'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
      self.run()
    File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
      self._target(*self._args, **self._kwargs)
    File "/Users/nisimond/work/blastarea/spinach/spinach/worker.py", line 121, in _worker_func
      advance_job_status(self._namespace, job, duration, e)
    File "/Users/nisimond/work/blastarea/spinach/spinach/job.py", line 198, in advance_job_status
      if job.should_retry:
         ^^^^^^^^^^^^^^^^
  AttributeError: 'tuple' object has no attribute 'should_retry'

    warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

tests/test_worker.py::test_can_accept_job[AsyncioWorkers]
  /Users/nisimond/work/blastarea/spinach/.tox/py3/lib/python3.11/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread tests-asyncio-worker

  Traceback (most recent call last):
    File "/Users/nisimond/work/blastarea/spinach/spinach/worker.py", line 194, in _worker_func
      await job.task_func(*job.task_args, **job.task_kwargs)
            ^^^^^^^^^^^^^
  AttributeError: 'tuple' object has no attribute 'task_func'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
      self.run()
    File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
      self._target(*self._args, **self._kwargs)
    File "/Users/nisimond/work/blastarea/spinach/spinach/worker.py", line 163, in _sync_interface_func
      asyncio.run(self._async_interface_func())
    File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
      return runner.run(main)
             ^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
      return self._loop.run_until_complete(task)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
      return future.result()
             ^^^^^^^^^^^^^^^
    File "/Users/nisimond/work/blastarea/spinach/spinach/worker.py", line 176, in _async_interface_func
      await asyncio.gather(*worker_futures)
    File "/Users/nisimond/work/blastarea/spinach/spinach/worker.py", line 197, in _worker_func
      advance_job_status(self._namespace, job, duration, e)
    File "/Users/nisimond/work/blastarea/spinach/spinach/job.py", line 198, in advance_job_status
      if job.should_retry:
         ^^^^^^^^^^^^^^^^
  AttributeError: 'tuple' object has no attribute 'should_retry'

    warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

If recent history is any guide, these can get upgraded to errors with little notice.