piccolo-orm / piccolo

A fast, user friendly ORM and query builder which supports asyncio.
https://piccolo-orm.com/
MIT License
1.41k stars 89 forks source link

Use `TableTest` to cut down boiler plate in tests #1030

Closed dantownsend closed 3 months ago

dantownsend commented 3 months ago

Almost all of our tests are like this:

class MyTest(TestCase):
    def setUp(self):
        # create tables

    def tearDown(self):
        # drop tables

Recently (when adding more SQL functions to Piccolo) we added a sub class of TestCase called TableTest, which cuts down the boiler plate of creating / dropping tables.

class MyTest(TableTest):  # The parent class creates / drops the tables for us
    tables = [MyTable]

We should move some of our existing tests over to use TableTest to remove boiler plate from the code base.