Installation
Introduction
CSTesting for Python is a testing framework with a test runner, assertions, API testing, and optional browser automation via Playwright. It mirrors the EasyTesting/CSTesting Node API. Use it from C:\CSTesting-Python or install from PyPI.
Install
# Core only (describe, it, expect — no browser)
pip install -e .
# With browser support (Playwright)
pip install -e ".[browser]"
playwright install chromium
If using the project at C:\CSTesting-Python, run the above from that directory (e.g. pip install -e "C:\CSTesting-Python[browser]" then playwright install chromium).
Quick start (unit tests)
Create a test file (e.g. math_test.py):
from cstesting import describe, it, expect
def _suite():
it("adds numbers", lambda: expect(1 + 1).to_be(2))
it("compares objects", lambda: expect({"a": 1}).to_equal({"a": 1}))
describe("Math", _suite)
Run tests:
python -m cstesting
python -m cstesting "**/*.test.py"
python -m cstesting example/math_test.py
Quick start (browser)
Requires pip install playwright && playwright install chromium.
import asyncio
from cstesting import describe, it, expect, before_all, after_all, create_browser
browser = None
def _suite():
def _before():
global browser
browser = asyncio.get_event_loop().run_until_complete(create_browser(headless=True))
def _after():
global browser
if browser:
asyncio.get_event_loop().run_until_complete(browser.close())
before_all(_before)
after_all(_after)
async def _test():
await browser.goto("https://example.com")
html = await browser.content()
expect(html).to_contain("Example Domain")
it("loads the page", _test)
describe("Browser", _suite)
API: create_browser(headless=True, browser='chromium'), browser.goto(url), browser.click(selector), browser.type(selector, text), browser.locator(selector) → .click(), .type(text), .first, .nth(n).
System requirements
- Python 3.8+
- Browser:
playwright install chromium(for browser automation). - OS: Windows, macOS, or Linux.