Last active
January 23, 2022 19:16
-
-
Save zengabor/5305917 to your computer and use it in GitHub Desktop.
**Custom prefix for Python unit test methods** (doing BDD in Python and wanted proper prefixes instead of the default 'test' prefix, and pytest had a bug: https://bitbucket.org/hpk42/pytest/issue/284/python_classes-and-python_functions)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
unittest.TestLoader.testMethodPrefix = 'should' | |
from unittest import TestCase as Specification | |
class MyClass(Specification): | |
def should_do_something(): | |
"""This method with the 'should' prefix will be picked up by test runners""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment