Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ description = "A blazing-fast Python HTTP client with TLS fingerprint"
readme = "README.md"
dynamic = ["version"]
license = { text = "GPL-3.0" }
authors = [
{ name = "0x676e67", email = "gngppz@gmail.com" }
]
authors = [{ name = "0x676e67", email = "gngppz@gmail.com" }]
keywords = ["http", "client", "websocket", "ja3", "ja4"]

[tool.maturin]
Expand All @@ -43,7 +41,5 @@ Documentation = "https://github.com/0x676e67/rnet/blob/main/rnet.pyi"
Homepage = "https://github.com/0x676e67/rnet"
Repository = "https://github.com/0x676e67/rnet"

[tool.poetry.dev-dependencies]
pytest = "^8.3.4"
pytest-asyncio = "^0.25.3"
pytest-rerunfailures = "^15.0"
[dependency-groups]
dev = ["pytest>=8.3.4", "pytest-asyncio>=0.25.3", "pytest-rerunfailures>=15.0"]
2 changes: 1 addition & 1 deletion src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{net::IpAddr, ops::Deref};

/// A client for making HTTP requests.
#[gen_stub_pyclass]
#[pyclass]
#[pyclass(subclass)]
pub struct Client(rquest::Client);

impl Deref for Client {
Expand Down
2 changes: 1 addition & 1 deletion src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use pyo3_stub_gen::derive::{gen_stub_pyclass, gen_stub_pymethods};

/// A blocking client for making HTTP requests.
#[gen_stub_pyclass]
#[pyclass]
#[pyclass(subclass)]
pub struct BlockingClient(async_impl::Client);

macro_rules! define_http_method {
Expand Down
29 changes: 28 additions & 1 deletion tests/client_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import pytest
import rnet
from rnet import Impersonate, ImpersonateOS, Cookie
from rnet import Cookie, Impersonate, ImpersonateOS


@pytest.mark.asyncio
@pytest.mark.flaky(reruns=1, reruns_delay=2)
async def test_inherit_client():
class SubClient(rnet.Client):
def __init__(self, **kwargs):
self.test_var = "test"
self.cookie_jar = None

client = SubClient(impersonate=Impersonate.Chrome133)
url = "https://google.com"
response = await client.get(url)
text = await response.text()
assert text is not None
assert client.cookie_jar is None
assert client.test_var == "test"
client.update(
impersonate=Impersonate.Firefox135,
impersonate_os=ImpersonateOS.Windows,
Impersonate_skip_headers=False,
)
assert (
client.user_agent
== "Mozilla/5.0 (Windows NT 10.0; rv:135.0) Gecko/20100101 Firefox/135.0"
)
assert client.test_var == "test"


@pytest.mark.asyncio
Expand Down
Loading