Skip to content

Where reasonable, convert tests to free functions #993

@gadomski

Description

@gadomski

We switched to pytest in #939, which means we don't have to use unittest.TestCase anymore; we can switch to free functions. In most cases, converting tests should be as simple as changing:

class MyTestCase(unittest.TestCase):
    def test_foo(self) -> None:
        self.assertTrue(True)

to

def test_foo() -> None:
    assert True

While this is a little bike-sheddy, this does have some benefits:

  • Enable fixtures, parameterization, and custom hooks
  • Reduces confusion for new contributors, who might be unsure of which test format to use
  • Reduces the indentation level (a little thing, I know, but IMO it reads cleaner to have less leading whitespace)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions