Skip to content
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ client = Browserbase(
session = client.sessions.create(
project_id=BROWSERBASE_PROJECT_ID,
)
```


def run(playwright: Playwright) -> None:
# Connect to the remote session
Expand Down Expand Up @@ -228,6 +226,8 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:

```python
import httpx

from browserbase import Browserbase

# Configure the default for all requests:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import annotations

import re
from pathlib import Path

README = Path(__file__).parent.parent / "README.md"


def python_blocks() -> list[str]:
return re.findall(r"```(?:py|python)\n(.*?)```", README.read_text(encoding="utf-8"), flags=re.DOTALL)


def test_quickstart_is_a_complete_python_block() -> None:
quickstart = next(block for block in python_blocks() if "sync_playwright" in block)

assert "def run(playwright: Playwright) -> None:" in quickstart
assert 'if __name__ == "__main__":' in quickstart
compile(quickstart, str(README), "exec")


def test_timeout_example_imports_httpx() -> None:
timeout_example = next(block for block in python_blocks() if "httpx.Timeout" in block)

assert "import httpx" in timeout_example
compile(timeout_example, str(README), "exec")