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.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

focused_unittest-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for focused_unittest-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0820c0085ce803bcd2ac1281dd6e358c739ba2b17275bd95db1656c48193350
MD5 3316020cdb8193405591202198789bfc
BLAKE2b-256 7d570fcc9348aef128203b96eda63811db767d8b93fbb1ae8b482b20735e7825

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for focused_unittest-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd2b13e62091ab143483aa0adb0d382d718f0a6249800747af0516c821254f7b
MD5 c1132f28f06da65f6718bfa4d99ff20f
BLAKE2b-256 c7f2de1b7137004b39558c33becb07492e190033b29ae1895ca41f2b9a164279

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