Skip to main content

A snake-cased drop in for unittest.TestCase

Project description

For historical reasons, Python's built-in unittest module is not PEP-8 compliant. It uses camel case method names instead of snake case names. This is not going to change in Python 3. (1, 2, 3)

This could lead to stylistic inconsistencies, especially if one wants to write custom assertion methods and runs a pep-8 checker over their test code.

To address this stylistic itch, uneedtest offers a simple drop-in TestCase class which provides snake cased aliases to all the camel cased methods in unittest.TestCase.

Install

pip install uneedtest

Use

You can use uneedtest.TestCase in the same way you used to use unittest.TestCase before. It accepts calls to the corresponding snake case methods. The camel case methods are still working, allowing for gradually fading out their use in your test code base:

from uneedtest import TestCase

class TestMe(TestCase):
    def test_something(self):
        self.assert_equal(1, 1)
        self.assertEqual(1, 1)

Test

You can run the tests using poetry:

poetry run pytest

If you don't want to use poetry, you can run the tests with pytest or unittest directly:

pytest tests/

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

uneedtest-0.1.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

uneedtest-0.1.0-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

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