A Python unit testing library
Project description
Pest Control
A Python Unit Testing Library
Usage
Test Functions:
- assertEquals(actual, expected, msg) - Test if actual = expected, if test fails, print out includes msg
- assertTrue(actual, msg) - Test if actual = True, if test fails, print out includes msg
- assertFalse(actual, msg) - Test if actual = False, if test fails, print out includes msg
How to
Start by importing the library. Assuming file is in same directory as the PestControl library directory: for example for the test script "basic_test.py", use the following folder structure for this example:
/
|- pestcontrol/
| - pest_control.py
|- basic_test.py
import pestcontrol
Then make a class that extends PestCase to be the unit test class (class name can be anything, "BasicTestCase" is used here)
class BasicTestCase(pestcontrol.PestCase):
Then write one or more functions for the actual test. NOTE: "test" MUST be somewhere in the function name. For example, add_test(), addTest(), addTesting(), add_Tester(), add_tester(), will all run, but add(), will not run.
class BasicTestCase(PestCase):
def add_test(self):
self.assertEquals(1+1, 2, "simple add test")
Now just add the main() funciton call
if __name__ == "__main__":
BasicTestCase().main()
That's it! Your unit test will run and print to the console the results. Note: any errors that occur from a call to an assert function, ie errors caused by the code being tested, will be caught and logged as a failed test (divide by zero error for example).
Full Example:
import pestcontrol
class BasicTestCase(pestcontrol.PestCase):
def add_test(self):
self.assertEquals(1+1, 2, "simple add test")
if __name__ == "__main__":
BasicTestCase().main()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pestcontrol-1.0.5.tar.gz.
File metadata
- Download URL: pestcontrol-1.0.5.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91a0bbdebc5980b3f0141231a893ccfd4a318b555d0a42c4de29dbb9ab268ea3
|
|
| MD5 |
841c394fee212fc1aaf88eba43f0f7c3
|
|
| BLAKE2b-256 |
6f728a86176ea0e364e7115be96dcf676c39ec4c9688c849ac222c2c3f9d7e96
|
File details
Details for the file pestcontrol-1.0.5-py3-none-any.whl.
File metadata
- Download URL: pestcontrol-1.0.5-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31ffafc1b39303a53d395cd5f0807fcda4fe20bad02e52cee7310e0bbe3c78f4
|
|
| MD5 |
2dc773c1e38325754e5af43206cd4dee
|
|
| BLAKE2b-256 |
fa8c748905a0ce5a03d7c7b12ddce61e5d4acb20293fdfd35233976c6d8dc339
|