0

Why is functional style testing facilitating testing compared to class based testing? Is this just additional library specific functionality or are there any general reasons to adopt functional style testing patterns?

To quote from pandas development guidelines:

pandas existing test structure is mostly class-based, meaning that you will typically find tests wrapped in a class.

class TestReallyCoolFeature:  
    pass

Going forward, we are moving to a more functional style using the pytest framework, which offers a richer testing framework that will facilitate testing and developing. Thus, instead of writing test classes, we will write test functions like this:

def test_really_cool_feature():
    pass
laterstat
  • 41
  • 1
  • 5

1 Answers1

0

There's an explanation in this PR comment. In short, the move from class-based testing to function-based testing is a consequence of pandas switching from nose to pytest.

Before the switch, almost every test was a method of a subclass of unittest.TestCase. pytest has very good support for running unittest tests, but there are some pytest features that can't be used inside unittest.TestCase subclasses. These incompatible features are listed in the pytest docs. One of them is @pytest.mark.parametrize. As the PR comment explains, the desire to use @pytest.mark.parametrize motivated the change in testing style.

David Wesby
  • 539
  • 1
  • 9
  • 19