Skip to main content

pyunit is wrapper for PyUnit (uniittest) framework with one important extension (syntax suger) by `@ test` decorator

Project description

PyUnit library

This is wrapper for standard unittest library for Python with custom TestRunner to run test suites. The main argument that this library was published is that standard unittest TestCase need test method prefix. This way with TestCase method prefix introduce the noise and if you have a lot small test methods in TestCase class then you still read test, and you are not focused on what do the test should test. I prefer the @test decorator or other solutions out of test method name to tell Your tests which method is registered as test in test runner, then You can focused to read method as poetry not as technical layer.

This library contains tool called pyunit to:

  • initiate the configuration file for suites
  • run tests automatically by pyunit run from command line

Installation:

user@host $ pip install pytheons.pyunit

Usage

user@host $ pyunit
--------------------------------------------------
PyUnit - unittest test runner based on annotation.

Usage: pyunit COMMAND --OPTION <argument>
  pyunit config init [--path=<path>]
  pyunit run [--suites=<suites>]
  pyunit (-h | --help)
  pyunit --version

Commands:
  config - Configuration sub-system
  suites - Tests Suites sub-system
  run    - Test runner from CLI

Options:
  -h --help     Show this screen.
  --version     Show version.
  1. Create the configuration by command pyunit config init [--path=path_to_your_test_configuration_dir]
  2. Create .py file to run all your tests. Below is content for this file:
    from pytheons.pyunit.suites.test_runner import TestRunner
    
    TestRunner.run()
    
  3. Write or Reorganise Your tests in structure test/<suite-name>/[optional subdir]/<test_name>.py
  4. Each test folder should be a package with __init__.py file - unittest throws exception that directory is not executable or callable
  5. Mark Your method by @test decorator from PyUnit library
    from unittest import TestCase
    from pytheons.pyunit.decorators.test import test
    
    class MyFirstTest(TestCase):
        @test
        def when_fuel_size_is_30_then_cost_should_be_300(self):
            fuel = 30
            self.assertEqual(300, FuelCalcuator.calculate(fuel))
    
  6. Run test by pyunit run or run .py file to run all tests

Attention! - Not full implement yet

  • --suites argument for pyunit run and test suites runner

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

pytheons.pyunit-1.0.3.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file pytheons.pyunit-1.0.3.tar.gz.

File metadata

  • Download URL: pytheons.pyunit-1.0.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytheons.pyunit-1.0.3.tar.gz
Algorithm Hash digest
SHA256 1351f58eb3f4aefd1be1837a8391ae06cffadc736a98343c8fbe291d6d3f5fff
MD5 634a2c868e71fb1347d91fe902425d0f
BLAKE2b-256 77add233eb3a122648b33cffa51883140438fd5f5c0ed69ac23abf18242b197f

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