Skip to content

Commit

Permalink
drop Python2 crumbs
Browse files Browse the repository at this point in the history
- old external "mock" module, this is now part of the Python standard library
  https://github.com/testing-cabal/mock
  "mock is now part of the Python standard library,
  available as unittest.mock in Python 3.3 onwards."

- "(object)" object notation: this is a no-op on Python3
  • Loading branch information
a-detiste authored and bamthomas committed Jan 16, 2025
1 parent c8cfb02 commit 79336b9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions aioimaplib/aioimaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def arguments_rfs2971(**kwargs: Union[dict, list, str]) -> Union[dict, list]:
return args


class Command(object):
class Command:
def __init__(self, name: str, tag: str, *args, prefix: str = None, untagged_resp_name: str = None,
loop: asyncio.AbstractEventLoop = None, timeout: float = None) -> None:
self.name = name
Expand Down Expand Up @@ -699,7 +699,7 @@ def _find_pending_async_cmd_by_tag(self, tag: str) -> list:
return [c for c in self.pending_async_commands.values() if c is not None and c.tag == tag]


class IMAP4(object):
class IMAP4:
TIMEOUT_SECONDS = 10.0
_client_task: Task

Expand Down
6 changes: 3 additions & 3 deletions aioimaplib/imap_testing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, *args) -> None:
super().__init__(*args)


class ServerState(object):
class ServerState:
DEFAULT_MAILBOXES = ['INBOX', 'Trash', 'Sent', 'Drafts']

def __init__(self):
Expand Down Expand Up @@ -670,7 +670,7 @@ def getquotaroot(self, tag, *args):
self.send_tagged_line(tag, 'OK GETQUOTAROOT completed.')


class MockImapServer(object):
class MockImapServer:
def __init__(self, capabilities=CAPABILITIES, loop=None) -> None:
self._server_state = ServerState()
self._connections = list()
Expand Down Expand Up @@ -725,7 +725,7 @@ def reset(self):
self._server_state.reset()


class Mail(object):
class Mail:
def __init__(self, email, date=datetime.now()):
self.date = date
self.email = email
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ python = "^3.9"
pytest = "^8.3"
pytest-asyncio = "^0.25"
pytest-rerunfailures = "^15.0"
mock = "^5.1"
pytz = "^2024"
tzlocal = "^5.2"
imaplib2 = "3.6"
Expand All @@ -43,4 +42,4 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
imap-testing-server = "aioimaplib.imap_testing_server:main"
imap-testing-server = "aioimaplib.imap_testing_server:main"
2 changes: 1 addition & 1 deletion tests/test_aioimaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import ssl
import unittest
from datetime import datetime, timedelta
from unittest.mock import call, MagicMock

import pytest
from mock import call, MagicMock
from pytz import utc

from aioimaplib import aioimaplib, extract_exists, STOP_WAIT_SERVER_PUSH, FetchCommand, IdleCommand
Expand Down
2 changes: 1 addition & 1 deletion tests/test_imapserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_reprocess_ids_if_a_message_is_removed(self):
assert 3 == server_state.max_uid('user', 'INBOX')


class WithImapServer(object):
class WithImapServer:
def _init_server(self, loop, capabilities=None, ssl_context=None):
self.loop = loop
if capabilities is not None:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_imapserver_imaplib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import asyncio

import functools

import time
from unittest.mock import Mock

from imaplib2 import imaplib2
from mock import Mock
from aioimaplib.imap_testing_server import Mail, IDLE, SELECTED
from tests.server_fixture import with_server, login_user
import pytest
Expand Down

0 comments on commit 79336b9

Please sign in to comment.