Skip to content

Commit

Permalink
[Tests] Fix missing __qualname__ for mock callback
Browse files Browse the repository at this point in the history
test_pop_alerts raised the following error:

    File "/home/runner/work/deluge/deluge/deluge/core/alertmanager.py", line 177, in handle_alerts
        handler=handler.__qualname__,
    File "lib/python3.10/unittest/mock.py", line 645, in __getattr__
        raise AttributeError(name)
    AttributeError: __qualname__

Mocks don't generate dunder methods like `__qualname__` attribute so
we need to manually specify it.
  • Loading branch information
cas-- committed Sep 6, 2024
1 parent 8867da9 commit 9d802b2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions deluge/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def reset(timeout=0.5, *args, **kwargs):
mock.deferred = deferred

mock = Mock()
mock.__qualname__ = 'mock'
original_reset_mock = mock.reset_mock
mock.reset_mock = reset
mock.reset_mock()
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
libtorrent
twisted[tls]>=17.1; sys_platform != 'win32'
twisted[tls]<23,>=17.1; sys_platform == 'win32'
twisted[tls]>=17.1
rencode
pyopenssl
pyxdg
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,7 @@ def run(self):

setup_requires = ['setuptools', 'wheel']
install_requires = [
"twisted[tls]>=17.1; sys_platform != 'win32'",
"twisted[tls]<23,>=17.1; sys_platform == 'win32'",
'twisted[tls]>=17.1',
# Add pyasn1 for setuptools workaround:
# https://github.com/pypa/setuptools/issues/1510
'pyasn1',
Expand Down

0 comments on commit 9d802b2

Please sign in to comment.