Remove autouse property of mock_sleep.

This commit is contained in:
erinhmclark
2025-03-13 15:23:35 +00:00
parent 16012df30b
commit 0bef78b0b4
6 changed files with 29 additions and 9 deletions

View File

@@ -7,6 +7,12 @@ from auto_archiver.modules.instagram_tbot_extractor import InstagramTbotExtracto
from tests.extractors.test_extractor_base import TestExtractorBase
@pytest.fixture(autouse=True)
def mock_sleep(mocker):
"""Mock time.sleep to avoid delays."""
return mocker.patch("time.sleep")
@pytest.fixture
def patch_extractor_methods(request, setup_module, mocker):
mocker.patch.object(InstagramTbotExtractor, "_prepare_session_file", return_value=None)

View File

@@ -151,14 +151,10 @@ class TestTiktokTikwmExtractor(TestExtractorBase):
assert result.get("timestamp") == datetime.fromtimestamp(1741122000, tz=timezone.utc)
@pytest.mark.download
def test_download_sensitive_video(self, make_item, mock_sleep):
# sleep is needed because of the rate limit
mock_sleep.stop()
time.sleep(1.1)
mock_sleep.start()
def test_download_sensitive_video(self, make_item):
url = "https://www.tiktok.com/@ggs68taiwan.official/video/7441821351142362375"
# Required for rate limiting
time.sleep(1.1)
result = self.extractor.download(make_item(url))
assert result.is_success()
assert len(result.media) == 2