{"id":18343409,"url":"https://github.com/cosimo/py-http-auto-test","last_synced_at":"2026-02-15T18:32:51.810Z","repository":{"id":191372904,"uuid":"684511938","full_name":"cosimo/py-http-auto-test","owner":"cosimo","description":"It's cosimo/http-cuke, but without the cucumber stuff","archived":false,"fork":false,"pushed_at":"2025-09-26T14:36:33.000Z","size":153,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-13T09:24:26.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cosimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-08-29T09:30:10.000Z","updated_at":"2025-09-26T14:36:37.000Z","dependencies_parsed_at":"2024-11-05T20:41:12.017Z","dependency_job_id":"d7a59c2c-8386-4340-936a-eab50b6812f3","html_url":"https://github.com/cosimo/py-http-auto-test","commit_stats":null,"previous_names":["cosimo/py-http-test"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/cosimo/py-http-auto-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fpy-http-auto-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fpy-http-auto-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fpy-http-auto-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fpy-http-auto-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosimo","download_url":"https://codeload.github.com/cosimo/py-http-auto-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Fpy-http-auto-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29486527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T15:33:17.885Z","status":"ssl_error","status_checked_at":"2026-02-15T15:32:53.698Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T20:35:57.136Z","updated_at":"2026-02-15T18:32:51.794Z","avatar_url":"https://github.com/cosimo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# py-http-auto-test: Python HTTP automated testing facility\n\n## What's this?\n\nThis is a simple HTTP testing library for Python.\n\nThe main idea is to be able to write simple YAML files that describe a suite of HTTP tests, and then run them either as a standalone script or as a [pytest](https://docs.pytest.org/en/latest/) test suite, with the provided [conftest.py](./conftest.py) plugin.\n\nA YAML test suite might look like this:\n\n```yaml\nbase_url: https://mysite.example.com\n\ntests:\n  - url: \"/\"\n    description: \"Fetch the index page\"\n    match:\n      status: 200\n      body:\n        - \"\u003c!DOCTYPE html\u003e\"\n  - url: \"/favicon.ico\"\n    description: \"Ensure the favicon file is present and served with the correct content type\"\n    match:\n      headers:\n        - \"content-type: image/x-icon\"\n      status: 200\n  - ...\n```\n\n## Why?\n\nOnce upon a time, there was [http-cuke](https://github.com/cosimo/http-cuke) which I made as an attempt to free myself of having to write tests. At that time, people believed that BDD/cucumber would enable not-necessarily technical people to write business logic test suites. I have personally never seen this happen.\n\nInstead of making the same mistake again, and learning from the past years of experience testing systems, I tried to write something that:\n\n- makes use of a solid HTTP library: libcurl, pycurl\n- covers websockets testing. [pycurl doesn't yet](https://github.com/pycurl/pycurl/issues/783)\n- minimizes the amount of code one needs to write to run a test suite\n\n## Some Use-Cases\n\n- When building a new package image/AMI, it's nice to be able to spawn a new instance and get a simple and clear answer to the question: *Can I online this instance? Will things work?*\n- Regression testing a web application\n- Live testing of a running system every x minutes\n\n## Requirements\n\nSee the [requirements.txt](requirements.txt) file for the full list of requirements. The main ones are:\n\n- Python 3.8 or later\n- The `libcurl4-openssl-dev` package on Debian-based systems, or `libcurl-devel` or whatever the equivalent on your system is, required to build `pycurl`\n- `pycurl` version 7+\n- `websockets` library to run tests against websockets\n\n### Optional Requirements\n\n- `pytest` if you want to run http tests as a pytest test suite\n\n## Installation\n\n```bash\nsudo apt-get update -qq\n# You need libcurl to build and install pycurl\nsudo apt-get install -y libcurl4-openssl-dev\npip install --upgrade py-http-auto-test\n```\n\n## Usage\n\nThere are two main ways to use this library:\n- standalone\n- pytest\n\n### Standalone\n\nThis distribution provides a `http-test-runner.py` script (usually installed in `/usr/local/bin`, or in your virtualenv's `bin` folder) that can be used to run one or more YAML test files.\n\nExamples:\n\n```bash\nhttp-test-runner.py --help\n\nhttp-test-runner.py --test-file website.yaml\n\n# Run the tests but against an alternative IP address\n# (this is similar to `MAP * \u003cip\u003e` in Chrome or `--connect-to *:*:\u003cip\u003e` in curl)\nhttp-test-runner.py --test-file website.yaml --target-host 127.0.0.1\n```\n\nThe library also supports template variables in the YAML files. This is useful if you want to define a set of tests for your web application, and then run them against different environments, for example:\n\n```yaml\n---\n# YAML test file\nbase_url: \"https://{{ hostname }}\"\ntests:\n  - url: \"/\"\n    description: \"Index page exists and it's served correctly\"\n    ...\n```\n\nand then:\n\n```bash\nhttp-test-runner.py --test-file website.yaml --var \"hostname=test.mydomain.com\"\n```\n\nThe `{{ hostname }}` variable will be replaced with `test.mydomain.com` in the test suite.\n\nThe template format is [jinja2](https://jinja.palletsprojects.com/en/).\n\n### pytest\n\nAll that was described for the standalone case works also as a pytest test suite. You need to make sure the provided `conftest.py` plugin is found when you run `pytest`.\n\nExample:\n\n```bash\npytest -v ./test.yaml\n```\n\nIf you need to pass on arguments or template variables, you can do so using environment variables prefixed with the string `HTTPTEST_`, as in:\n\n```bash\nHTTPTEST_TARGET_HOST=\"127.0.0.1\" HTTPTEST_TEMPLATE_VARS=\"hostname=test.mydomain.com\" pytest -v ./test.yaml\n```\n\nTo pass on multiple environment variables, use a space character to separate multiple values, as in:\n\n```bash\nHTTPTEST_TARGET_HOST=\"127.0.0.1\" HTTPTEST_TEMPLATE_VARS=\"hostname=test.mydomain.com protocol=https\" pytest -v ./test.yaml\n```\n\n## Comprehensive Example of a Single Test\n\nAn HTTP test has a bunch of attributes, some of which are optional. The following is a semi-complete example:\n\n```yaml\n- url: \"/index.html\"\n\n  description: \"Verify that we can correctly download the index page as gzip-compressed response\"\n\n  headers:\n    - \"accept: text/html\"\n    - \"accept-encoding: gzip\"\n\n  http2: true     # false (http/1.1) is the default\n\n  # Skip a temporarily failing test by adding the `skip` attribute\n  skip: true      # false is the default\n\n  # Output the request and response dump with the test outcome\n  verbose: true   # false is the default\n\n  # Here is where you specify the test requirements\n  match:\n\n    # Response HTTP status must be 200 for the test to pass\n    # This can also be a list of status codes\n    status: 200\n\n    # Verify that the response matches the following headers.\n    # Header names will be matched regardless of upper or lower case.\n    headers:\n      - \"content-type: text/html\"\n      - \"content-encoding: gzip\"\n\n    # Verify that the response body contains the specified string patterns\n    body:\n      - \"\u003c!DOCTYPE html\u003e\"\n      - \"\u003ch1\u003eHello\u003c/h1\u003e\"\n\n    # Verify that the request took less than 500ms\n    timing: 500ms\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosimo%2Fpy-http-auto-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosimo%2Fpy-http-auto-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosimo%2Fpy-http-auto-test/lists"}