Skip to main content

A simple testing system based on files

Project description

Naive Tester

PyPI version

A simple testing system based on files. You provide a name of a script to be tested and a folder containing files with arguments and reference outputs. The app runs the script with the arguments from a file and compares its result with that from the corresponding reference output file. The following naming convention is applied: each set of arguments is stored in the '.in' file, while the corresponding output in the '.out' file, i.e., 'test_0.in' and 'test_0.out'. Each pair must have identical names except for extensions.

Installation

The Naive Tester can be installed from PyPi:

$ pip install naive-tester

The tester supports Python 3.6 and above. It is recommended to use virtual environments for installation.

How to use

Assume you created a python script some_app.py and want to test it. Your app takes a string as an argument and outputs the length of that string to the console. The application call might look like this:

$ python some_app.py input_string
$ 12

The first step is to prepare the tests, in this case, is to create a bunch of files. Those with the '.in' extension must contain script arguments, i.e., 'input_string' from the example above, and those with '.out' extension containing expected output, i.e., '12'. The latter will be used for comparison with the script's output. In other words, each pair of the files represents one test case.

some_app/
|
├── tests
|   ├── test_0.in
|   ├── test_0.out
|   ├── test_1.in
|   ├── test_1.out
|   ...
└── some_app.py

After the preparation step, you can run all the tests with the following command:

$ tester some_app.py tests

If you want the output to be more verbose, use the -v option:

$ tester -v some_app.py tests

Example outputs will be like the following:

Successfully run the some_app.py.
Elapsed time: 0.15s
Run of the some_app.py failed.
Elapsed time: 0.07s

or (for verbose option):

Successfully run the some_app.py. With arguments ['12345678'] got the output of 8.
Elapsed time: 0.15s
Failed run of the some_app.py with ['12345678']. The output should be 8, but got 7.
Elapsed time: 0.06s

It is possible to save the output to a file using a standard Linux technique:

$ tester some_app.py tests > test_report.txt

If your script has more than just one argument, then to use it with the naive-tester, you should list the arguments on new lines in the '.in' files.

Release History

  • 1.0.0
    • 1.0.1 Minor bug fixes
  • 1.1.0 Added timer for each script execution; logging stream handler changed from stderr to stdout
  • 1.2.0 Added support for multiple script arguments
    • 1.2.1 Added an option for the verbose output

License

This project is licensed under the MIT License - see the LICENSE file for details

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

naive-tester-1.2.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

naive_tester-1.2.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file naive-tester-1.2.1.tar.gz.

File metadata

  • Download URL: naive-tester-1.2.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.4

File hashes

Hashes for naive-tester-1.2.1.tar.gz
Algorithm Hash digest
SHA256 11634ecb6bdb672028670878d363c107a170b351159a71bdebf56d9132c3a52f
MD5 658a8483a7e2bbb5c5d133071e4e73a6
BLAKE2b-256 f150914a58f090af1dd8234cbb6e75cd0ae1dc831aa962cc706d139f7dab5299

See more details on using hashes here.

File details

Details for the file naive_tester-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: naive_tester-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.4

File hashes

Hashes for naive_tester-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfc07f5f0990715653f63ae7eef4026a043851e62f0ce74cbc317fb2b97da2da
MD5 f7c635f7fcb2bbcbf2907cabee6d4c9d
BLAKE2b-256 3f6b6afba925a1b258e4a900de6197d64dcee956f0ae16a77b7aa17854f77236

See more details on using hashes here.

Supported by

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