Skip to main content

light test runner for Python

Project description

=====
ptest
=====
ptest is light testing framework for Python.

Installation
------------
The last stable release is available on PyPI and can be installed with ``pip``
::
$ pip install ptest

Example
-------
You can specify test class, test, before method, after method by adding decorator @TestClass, @Test, @BeforeMethod, @AfterMethod.

c:\\test.py

.. code:: python

from ptest.decorator import TestClass, Test, BeforeMethod, AfterMethod
from ptest.assertion import assert_equals, assert_true, fail

@TestClass(run_mode="singleline")
class PTestClass:
def __init__(self):
self.expected = 1

@BeforeMethod(description="Prepare test data.")
def before(self):
self.expected = 10

@Test(tags=["regression"])
def test1(self):
assert_equals(10, self.expected) # pass

@Test(tags=["smoke"])
def test2(self):
assert_true(False) # failed

@Test(enabled=False)
def test3(self):
fail("failed") # won't be run

@AfterMethod(always_run=True, description="Clean up")
def after(self):
self.expected = None

Then start to execute the tests.
Use -w to specify the workspace and -t to specify the target.
::
$ ptest -w c: -t test

The target can be package/module/class/method.
If the target is package/module/class, all the test cases under target will be executed.
::
$ ptest -t pack.sub.module.class

If you have multiple targets, just separate them by comma.
::
$ ptest -t packa.mo,packb

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

ptest-0.0.1.zip (72.1 kB view hashes)

Uploaded Source

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