Skip to main content

A modern testing framework

Project description

Viper

A modern testing framework.

Basic Tests

Viper was made for people of all types and expertise. To make a simple test, you can use the following code:

from viper import Viper

snake = Viper("Example Tests")

def addition(a, b):
    return a + b

snake.test("check if addition function can solve 5 + 5", addition(5, 5), 10)

snake.evaluate()

On running this, you should get:

Running tests for "Example Tests"
Testing "check if addition function can solve 5 + 5"... Passed

Ran 1 test(s) in 0.0004 seconds
1/1 passed

And if we change the 10 to become something else like so:

snake.test("check if addition function can solve 5 + 5", addition(5, 5), 7)

The output becomes:

Running tests for "Example Tests"
Testing "check if addition function can solve 5 + 5"... Failed
   Desired Output: "7" | Test Ouput: "10"

Ran 1 test(s) in 0.0006 seconds
0/1 passed

As one can see, the testing outputs are made so that it is simple, yet it is also informative

API Testing

Viper can also be used as an API test:

from viper import Viper
import requests

snake = Viper("Example Tests")

def checkCompletion():
    return requests.get("https://jsonplaceholder.typicode.com/todos/1").json()["completed"]

snake.test("check if todo is completed or not", checkCompletion(), False)

snake.evaluate()

The output of that is:

Running tests for "Example Tests"
Testing "check if todo is completed or not"... Passed

Ran 1 test(s) in 0.0009 seconds
1/1 passed

Importing and Exporting Tests

With Viper, you can import and export tests, something that is hard to do with other frameworks. For example, say you have two files, a.py and b.py. a.py:

from viper import Viper

snake = Viper("Example Tests")

def addition(a, b):
    return a + b

snake.test("check if addition function can solve 5 + 5", addition(5, 5), 10)

def export():
    return snake.tests

b.py:

from a import export
from viper import Viper

snake = Viper("Importing data")

snake.importFromFile(export())

snake.evaluate()

Running, b.py gives us the output of:

Running tests for "Importing data"
Testing "check if addition function can solve 5 + 5"... Passed

Ran 1 test(s) in 0.0002 seconds
1/1 passed

As one can see, the importing and exporting works.

Copyrighted

Copyright © 2020-2021 Aarush Gupta

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viper-tests-0.2.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viper_tests-0.2.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file viper-tests-0.2.2.tar.gz.

File metadata

  • Download URL: viper-tests-0.2.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.3.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for viper-tests-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ba141beadc4a61c5e7e0a09ecbbda58e31f5d37f4716ad4de4142504eb04e87e
MD5 d4dbef6a77ddd3fd0289af9c75fae323
BLAKE2b-256 c5952513a57204c8cfbf8518d34d0c8d9467518231a1a7f5fc907180f0bffb55

See more details on using hashes here.

File details

Details for the file viper_tests-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: viper_tests-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.3.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for viper_tests-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32ba88d7b350b254684359b0f7935fc4e13c291cdcb5adf4e14f9c9d0af3440b
MD5 820c681ec0f33df6d906a7456254f363
BLAKE2b-256 ff55440b9055e08e42f8dbce84c09f4c52ca9b1afe571cd3eb71757121cfa48a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page