-
-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: fix impersonate=chrome not working, check the return value of…
… impersonate
- Loading branch information
Showing
3 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from curl_cffi import requests | ||
from curl_cffi.const import CurlHttpVersion | ||
|
||
|
||
def test_impersonate_with_version(server): | ||
# the test server does not understand http/2 | ||
r = requests.get(str(server.url), impersonate="chrome120", http_version=CurlHttpVersion.V1_1) | ||
assert r.status_code == 200 | ||
r = requests.get(str(server.url), impersonate="safari17_0", http_version=CurlHttpVersion.V1_1) | ||
assert r.status_code == 200 | ||
|
||
|
||
def test_impersonate_without_version(server): | ||
r = requests.get(str(server.url), impersonate="chrome", http_version=CurlHttpVersion.V1_1) | ||
assert r.status_code == 200 | ||
r = requests.get(str(server.url), impersonate="safari_ios", http_version=CurlHttpVersion.V1_1) | ||
assert r.status_code == 200 | ||
|
||
|
||
def test_impersonate_non_exist(server): | ||
with pytest.raises(requests.RequestsError, match="Impersonating"): | ||
requests.get(str(server.url), impersonate="edge") | ||
with pytest.raises(requests.RequestsError, match="Impersonating"): | ||
requests.get(str(server.url), impersonate="chrome2952") |