Perform fast and detailed unit tests with BuPyTest.
Project description
BuPyTest - Unit Tests
BuPyTest is a library to perform unit tests on your code by classes. You can create tests using classes and run them together in a single file.
In version 0.1.0
you can:
- Test multiple classes in one file;
- Test using command line;
- Test multiple files using command line;
- Test only one file using command line;
You can install the latest version of BuPyTest using the pip
package manager:
pip install bupytest
How to use
Here's a simple tutorial on how to use bupytest
in your tests:
In the base class
bupytest.BaseTest
all tests are executed in the order they were defined (sequential).
import bupytest
class TestFoo(bupytest.UnitTest):
def __init__(self):
super().__init__()
def test_1(self):
self.assert_true(True, message='A error ocurred')
def test_2(self):
false_value = ''
self.assert_false(false_value, message='Empty string')
if __name__ == '__main__':
bupytest.this()
With bupytest
, you define test classes and the methods, which will be tested. To test a value, you can use the following methods of the bupytest.UnitTest
class:
UnitTest.assert_true
: asserts a true value;UnitTest.assert_false
: asserts a false value;UnitTest.assert_expected
: asserts an expected value.
All test classes must start with "Test", and all test class methods must start with "test_".
At the end of the file, the bupytest.this
method runs the test in this file. That is, all test classes in this file will be executed.
You can also define several other classes in the same file for testing:
import bupytest
class TestFoo(bupytest.UnitTest):
def __init__(self):
super().__init__()
def test_1(self):
self.assert_true(True, message='A error ocurred')
def test_2(self):
false_value = ''
self.assert_false(false_value, message='Empty string')
class TestBar(bupytest.UnitTest):
def __init__(self):
super().__init__()
def test_1(self):
self.assert_expected('hello', 'hello')
if __name__ == '__main__':
bupytest.this()
License
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file bupytest-0.1.0.tar.gz
.
File metadata
- Download URL: bupytest-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b8a2d62461598245a9c5892ba4d01c3b565f2a024f587f4714ed9c5b48be35e |
|
MD5 | 5783c0807b5bc9ae7555625b139a616c |
|
BLAKE2b-256 | 05151e31602fca84cf565060b1fdac50e74c48b999b36f197519ad1a445e69cb |