Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

tests: Updating tests according to the new changes

Karim shoair8b46e3a3a5f5
diff --git a/tests/fetchers/async/test_playwright.py b/tests/fetchers/async/test_dynamic.py
similarity index 94%
rename from tests/fetchers/async/test_playwright.py
rename to tests/fetchers/async/test_dynamic.py
index 732bba1..9874858 100644
--- a/tests/fetchers/async/test_playwright.py
+++ b/tests/fetchers/async/test_dynamic.py
@@ -1,16 +1,16 @@
import pytest
import pytest_httpbin
-from scrapling import PlayWrightFetcher
+from scrapling import DynamicFetcher
-PlayWrightFetcher.auto_match = True
+DynamicFetcher.auto_match = True
@pytest_httpbin.use_class_based_httpbin
-class TestPlayWrightFetcherAsync:
+class TestDynamicFetcherAsync:
@pytest.fixture
def fetcher(self):
- return PlayWrightFetcher
+ return DynamicFetcher
@pytest.fixture
def urls(self, httpbin):
@@ -94,10 +94,10 @@ class TestPlayWrightFetcherAsync:
@pytest.mark.asyncio
async def test_cdp_url_invalid(self, fetcher, urls):
"""Test if invalid CDP URLs raise appropriate exceptions"""
- with pytest.raises(ValueError):
+ with pytest.raises(TypeError):
await fetcher.async_fetch(urls["html_url"], cdp_url="blahblah")
- with pytest.raises(ValueError):
+ with pytest.raises(TypeError):
await fetcher.async_fetch(
urls["html_url"], cdp_url="blahblah", nstbrowser_mode=True
)
@@ -108,5 +108,5 @@ class TestPlayWrightFetcherAsync:
@pytest.mark.asyncio
async def test_infinite_timeout(self, fetcher, urls):
"""Test if infinite timeout breaks the code or not"""
- response = await fetcher.async_fetch(urls["delayed_url"], timeout=None)
+ response = await fetcher.async_fetch(urls["delayed_url"], timeout=0)
assert response.status == 200
diff --git a/tests/fetchers/sync/test_playwright.py b/tests/fetchers/sync/test_dynamic.py
similarity index 93%
rename from tests/fetchers/sync/test_playwright.py
rename to tests/fetchers/sync/test_dynamic.py
index cadb9b5..fdefdf1 100644
--- a/tests/fetchers/sync/test_playwright.py
+++ b/tests/fetchers/sync/test_dynamic.py
@@ -1,17 +1,17 @@
import pytest
import pytest_httpbin
-from scrapling import PlayWrightFetcher
+from scrapling import DynamicFetcher
-PlayWrightFetcher.auto_match = True
+DynamicFetcher.auto_match = True
@pytest_httpbin.use_class_based_httpbin
-class TestPlayWrightFetcher:
+class TestDynamicFetcher:
@pytest.fixture(scope="class")
def fetcher(self):
"""Fixture to create a StealthyFetcher instance for the entire test class"""
- return PlayWrightFetcher
+ return DynamicFetcher
@pytest.fixture(autouse=True)
def setup_urls(self, httpbin):
@@ -85,10 +85,10 @@ class TestPlayWrightFetcher:
def test_cdp_url_invalid(self, fetcher):
"""Test if invalid CDP URLs raise appropriate exceptions"""
- with pytest.raises(ValueError):
+ with pytest.raises(TypeError):
fetcher.fetch(self.html_url, cdp_url="blahblah")
- with pytest.raises(ValueError):
+ with pytest.raises(TypeError):
fetcher.fetch(self.html_url, cdp_url="blahblah", nstbrowser_mode=True)
with pytest.raises(Exception):
@@ -99,5 +99,5 @@ class TestPlayWrightFetcher:
fetcher,
):
"""Test if infinite timeout breaks the code or not"""
- response = fetcher.fetch(self.delayed_url, timeout=None)
+ response = fetcher.fetch(self.delayed_url, timeout=0)
assert response.status == 200