Skip to main content

deploy-package

testhttp

testhttp allows you to send HTTP request for testing your endpoints. This is still very incomplete but satisfy my needs at the moment. Feel free to suggest or create changes for updates.

Features

  • The goal is to be compatible with vscode-restclient but with ability to assert results and automate dependencies.
  • Run named or by index http definition
  • Import other files to re-use http definition
  • Set global variables as a context for the scripts

Install

pip install testhttp
# -h for help
testhttp -h

# Run a file
testhttp --file sample.http

# Run all files based on glob pattern
testhttp --pattern '/Users/path/to/**/test/*.http'
# Declaring a global variable that will be available for all scripts
testhttp --var host=https://baseurl/
# Automatically remove steps with the same name
testhttp --distinct

Usage

In editor, type an HTTP request as simple as below:

https://example.com/comments/1

###

# @name postToExample
POST https://example.com/comments HTTP/1.1
content-type: application/json

{
    "name": "sample",
    "time": "Wed, 21 Oct 2015 18:27:50 GMT"
}

>>>

assert {{response.status_code}} == 404

Save it as sample.http then run the command below:

# add --verbose to see request and response information 
# add --debug for debug info
testhttp --file.sample.http --name postToExample

Import

You can import other files by:

@import other_file.http

###

... rest of your http info

This will do a lookup relative to current file. Without specifying --name or --index it will still only run all tests under the current file and will only run things it depends on.

Variables & Dependencies

Running by name will result in execution of it's variable dependencies. This way you can only test specific spec and it will still work with single command.

@user = hello
@password = world
@baseUrl = https://example.com

# @name login
POST {{baseUrl}}/api/login HTTP/1.1
content-type: application/json

{
    "username": "{{user}}",
    "password": "{{password}}"
}

>>>

assert {{response.status_code}} == 200

###

@token = {{login.response.body.token}}

# @name getCurrentUser
GET {{baseUrl}}/api/me HTTP/1.1
content-type: application/json
Authorization: {{token}}

>>>

assert {{response.status_code}} == 200
assert {{response.body.username}} == {{user}}

Running only getCurrentUser will automatically run login since it depends on login in the token variable.

Metadata

Release files for testhttp 0.6.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for testhttp 0.6.6
File Size Uploaded Provenance Actions
testhttp-0.6.6.tar.gz 7.5 kB Without provenance Details for testhttp-0.6.6.tar.gz

Release files / testhttp-0.6.6.tar.gz

Download URL testhttp-0.6.6.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2d828d060e62146f7f4c6c2410e0665858a1a14ed1019ad5f8f1083390eb881f
BLAKE2b-256 checksum
How to use checksums
4ee4bf7187f0538da443cc6bcf8dda862da457e22aa40aa4f03993059dc2211d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Security for testhttp 0.6.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page