Skip to main content

Decorator to select only one unit test to be run.

Project description

What is it for?

I use it when I need to debug only one test and I don't want to deal with command line parameters or modification of unittest.main().

Installation

!pip install focused_unittest

Usage

# test_example.py
import unittest
from focused_unittests import FocusedTestCase, focus

class TestExample(FocusedTestCase):

    @focus
    def test_add(self):
        self.assertEqual(2 + 3, 5)

    @focus
    def test_subtract(self):
        self.assertEqual(3 - 2, 1)

    def test_multiply(self):
        self.assertEqual(3 * 2, 6)

    def test_divide(self):
        self.assertEqual(6 / 2, 3)

if __name__ == '__main__':
    unittest.main()

Basically I change unittest.TestCase to FocusedTestCase and I add @focus decorator to the methods I need to debug. Now I can debug with just F5 in vscode.

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

focused_unittest-0.1.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

focused_unittest-0.1.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file focused_unittest-0.1.1.tar.gz.

File metadata

  • Download URL: focused_unittest-0.1.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for focused_unittest-0.1.1.tar.gz
Algorithm Hash digest
SHA256 868d9bffb6b139c24c218959785b6462bc3f5773b0d8950c3cf8a99436fb05fa
MD5 43b50742bec65e6662cd3eaa0403baa3
BLAKE2b-256 8992482fe8bf6201d1be6520892df115cde0c34039bcad71e350662ef4b9332d

See more details on using hashes here.

File details

Details for the file focused_unittest-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for focused_unittest-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc46a95f1d0e965a1d36391abcb2c4198d3676b8a3c2bd41306a5aea4f4dc033
MD5 725a4438408cb55a325d1c18101f9875
BLAKE2b-256 52eb16b43196014960a78a1a267094dc5f6bb8cadb194648a1649199756c9a42

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