Skip to main content

Multtestlib, a package developed for performing unit tests in Python using multiprocessing.

Project description

multtestlib: A package developed for performing unit tests in Python using multiprocessing.

Multtestlib has been devised to aid Python testers in expediting their testing processes through multiprocessing. This approach allows customizable utilization of the computer's available processor cores, facilitating workload distribution and consequent reduction in the overall execution time of the test suite.


GitHub release Python License Downloads

Installation

Multtestlib is available on PyPi and can be installed using the pip command:

pip install multtestlib

Requirements

Multtestlib requires Python 3.7 or later to run.


Usage

For multiprocessing usage, the input parameters of the test functions and their respective expected values must be stored in lists. During the test processing, multtestlib will take care of distributing and managing the data contained in the lists - and functions - among the processor cores indicated in the test program.

Here are some code snippets illustrating the usage of multtestlib:

# It is strongly recommended to create a test function to be called by the main() function.

import multtestlib as mtl
import functions

def tester():

    # Detects the maximum number of CPUs available in the system
    cpu = mtl.max_cpu()

    input_values1 = []
    input_values2 = []
    return_values = []
	
    # It is necessary to store the input data and
    # expected values in their respective lists.

    mtl.test_equal(cpu, input_values1, input_values2, return_values, functions.myfunction)

    # Parameters can be omitted, when necessary, by using "":
    mtl.test_equal(cpu, input_values1, "", return_values, functions.myfunction)

    # The code units to be tested can also be stored in lists:
    list_functions = [functions.add,
                      functions.add,
                      ...
                      functions.subtract,
                      functions.subtract]
   
    # When testing methods of a class, create a function (outside of the class) to invoke it:
      def method(object):
          return object.method()
    

if __name__ == "__main__":
    mtl.init()
    tester()
    mtl.end()

Output Files

During the execution of the unit tests, three output files are generated containing the results of the tests performed.

filepass.txt -> Contains passed tests
filefail.txt -> Contains failed tests
filetot.txt -> Contains all tests

List of testing commands

table


MIT License

Copyright (c) 2022-2024 Ricardo Ribeiro de Alvarenga

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

multtestlib-1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

multtestlib-1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file multtestlib-1.1.tar.gz.

File metadata

  • Download URL: multtestlib-1.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for multtestlib-1.1.tar.gz
Algorithm Hash digest
SHA256 245e2c42f903344c2d197878eb5c052a698f8d51db2c76418da8e4df276a8d61
MD5 f8703ca5e5425f3229d141a47fbf516a
BLAKE2b-256 d40cc146d5db49dc7efd1d023af824a08c0422a82f4b12f86ec524d5b1902108

See more details on using hashes here.

File details

Details for the file multtestlib-1.1-py3-none-any.whl.

File metadata

  • Download URL: multtestlib-1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for multtestlib-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92f72cd4987f0b3866699ea5b2b4b037be1c3e31178958810d274f6efa1c4b1a
MD5 3a05f529b3afe9fc039e66280ebb211b
BLAKE2b-256 71a6cad98327bd17efd1cfba3abe4188ffb8600eeaebf27c021e249ca18b0cb9

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