Skip to main content

Pyt

Pyt is a lightweight wrapper around Python's unittest module that adds some nice features and enhancements over the stock unittest module.

Quickstart

Pyt overrides unittest's built-in pathfinding to be smarter and less verbose, so you can match tests using prefix matching which makes running a test like:

$ python -m unittest tests.foo_test.BarTestCase.test_che

as simple as:

$ pyt foo.Bar.che

But it's even less verbose if you want it to be, pyt can reach into the modules and classes to do its matching, so you don't even need to specify the module and class if you don't want to:

$ pyt che

More examples

To run all the Happy tests:

$ pyt Happy

To run all the newmodule tests:

$ pyt newmodule

To run more than one test:

$ pyt test1 test2 ...

To run every test pyt can find:

$ pyt

And the way I like to run all tests in the current directory:

$ pyt -vb

Which can also be written:

$ pyt --verbose --buffer

Flags

To see everything pyt can do

$ pyt --help

--warnings

This will convert warnings into errors.

$ pyt --warnings

--rerun

If your last testrun had failing tests this will rerun only the tests that failed.

$pyt --rerun

Things to be aware of

pyt uses Python's PEP 8 style conventions

pyt uses Python's code styling conventions to decide what is the module and class, so, given input like this:

$ pyt foo.bar.Baz.che

pyt will consider foo.bar to be the module, Baz to be a class (because it starts with a capital letter), and che to be a method (since it comes after the class).

Likewise, pyt uses unittest conventions, so a test module should end with _test (eg, foo.bar_test) or start with test (eg, test_foo.py) and a TestCase class should extend unittest.TestCase, and test methods should start with test_ (eg, test_che).

Vague input can cause pyt to run more tests than you expect

So if you have something like this:

project/
  __init__.py
  user.py
  foo/
    __init__.py
    user.py
  tests/
    __init__.py
    user_test.py
    foo/
      __init__.py
      user_test.py

And you want to run tests for foo.user and you run:

$ pyt user

it will run both tests/user_test and tests.foo.user_test, the solution is to just be more verbose when you have to be:

$ pyt foo.user

Environment Variables

If you are running the tests within pyt, you might notice there is an environment variable PYT_TEST_COUNT that contains the count of how many tests pyt found to run.

Installation

Use pip:

$ pip install pyt

You can also get it directly from the repo:

$ pip install --upgrade git+https://github.com/Jaymon/pyt#egg=pyt

Testing

Testing on MacOS:

$ python -m unittest discover

Or, if you're really brave, you can use pyt to test itself:

$ python -m pyt tests -df

Release files for pyt 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyt 1.4.0
File Size Uploaded
pyt-1.4.0.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyt 1.4.0
File Interpreter ABI Platform
pyt-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.3 kB

Release files / pyt-1.4.0.tar.gz

Download URL pyt-1.4.0.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
09a12322f7027953b1195ea657b2b82f3c4d0b38df622bdaa6c8ff29674be216
BLAKE2b-256 checksum
How to use checksums
a6ab8dc7ce297f520debde730c203b23050f7b309eeed2a740a20756193a4fe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.14

Release files / pyt-1.4.0-py3-none-any.whl

Download URL pyt-1.4.0-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67f2705a81c02039eb11f5fde898e56c2add39b7909b326db36b2fc04e547393
BLAKE2b-256 checksum
How to use checksums
a29072dbe159af112544bf7194e1e0eccb3f5011328cd0503237eb1914d9b21c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.14

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.0

2 release files

1.0.5

1 release file

0.7.31

1 release file

0.7.29

1 release file

0.7.28

1 release file

0.7.27

1 release file

0.7.26

1 release file

0.7.25

1 release file

0.7.24

1 release file

0.7.23

1 release file

0.7.22

1 release file

0.7.15

1 release file

0.7.14

1 release file

0.7.13

1 release file

0.7.12

1 release file

0.7.11

1 release file

0.7.10

1 release file

0.7.9

1 release file

0.7.7

1 release file

0.7.6

1 release file

0.7.5

1 release file

0.7.4

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.6.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page