Need direction for writing tests

Hi everyone I was working on my first patch for django, Using subquery to filter a model delete generates a sub-optimal SQL by salty-ivy · Pull Request #16809 · django/django · GitHub

I checked out the tests in tests/backend/base/test_features and similar for mysql. It’s little unclear if I should write tests for the existence of the feature flags or their behavior ?

Hi @salty-ivy, welcome!

Reading Simon’s comment on the PR, you should be able to do something like this in the test case he points to:

if connection.features.delete_can_self_reference_subquery:
    # asserting that sql.count('SELECT') equals 1 here. 

If you search the test suite for connection.features you can see how it’s used.

1 Like