mirror of
https://github.com/certbot/certbot.git
synced 2026-06-08 16:22:18 -04:00
Speed up mac tests using various strategies (#10419)
Alternative to https://github.com/certbot/certbot/pull/10408/ and https://github.com/certbot/certbot/pull/10415/ that fixes production code for account meta and puts autouse fixtures in certbot and acme tests. Overrides all `time.sleep` calls while we're at it. Fixes the production code where it's simple/clean, and fixes the tests for HTTPServer-based code because we just don't have that many mac users using standalone.
This commit is contained in:
parent
bd796deaa3
commit
801894c7da
4 changed files with 34 additions and 2 deletions
16
acme/src/acme/_internal/tests/conftest.py
Normal file
16
acme/src/acme/_internal/tests/conftest.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
# This avoids a bug on mac where getfqdn errors after a long timeout.
|
||||
# See https://bugs.python.org/issue35164
|
||||
# and discussion at https://github.com/certbot/certbot/pull/10408
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_getfqdn():
|
||||
with mock.patch("socket.getfqdn", return_value="server_name") as mocked:
|
||||
yield mocked
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_sleep():
|
||||
with mock.patch("time.sleep") as mocked:
|
||||
yield mocked
|
||||
|
|
@ -62,7 +62,7 @@ class Account:
|
|||
self.meta = self.Meta(
|
||||
# pyrfc3339 drops microseconds, make sure __eq__ is sane
|
||||
creation_dt=datetime.datetime.now(tz=datetime.timezone.utc).replace(microsecond=0),
|
||||
creation_host=socket.getfqdn(),
|
||||
creation_host=socket.gethostname(),
|
||||
register_to_eff=None) if meta is None else meta
|
||||
|
||||
# try MD5, else use MD5 in non-security mode (e.g. for FIPS systems / RHEL)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class AccountTest(unittest.TestCase):
|
|||
self.regr.__repr__ = mock.MagicMock(return_value="i_am_a_regr")
|
||||
|
||||
with mock.patch("certbot._internal.account.socket") as mock_socket:
|
||||
mock_socket.getfqdn.return_value = "test.certbot.org"
|
||||
mock_socket.gethostname.return_value = "test.certbot.org"
|
||||
with mock.patch("certbot._internal.account.datetime") as mock_dt:
|
||||
mock_dt.datetime.now.return_value = self.meta.creation_dt
|
||||
self.acc_no_meta = Account(self.regr, KEY)
|
||||
|
|
|
|||
16
certbot/src/certbot/_internal/tests/conftest.py
Normal file
16
certbot/src/certbot/_internal/tests/conftest.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
# This avoids a bug on mac where getfqdn errors after a long timeout.
|
||||
# See https://bugs.python.org/issue35164
|
||||
# and discussion at https://github.com/certbot/certbot/pull/10408
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_getfqdn():
|
||||
with mock.patch("socket.getfqdn", return_value="server_name") as mocked:
|
||||
yield mocked
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_sleep():
|
||||
with mock.patch("time.sleep") as mocked:
|
||||
yield mocked
|
||||
Loading…
Reference in a new issue