I'm fairly shocked there's already no test for this, my fault. a test needs to be written, which I can do at some point or if you want to write one in test_autogenerate that would be great (though there's no existing pattern there for testing comparison code, I'd push to keep it simple), before this is merged.
Probably there's an easier way to test the fact that either all columns are excluded or all columns are excluded than comparing the string from the template, but I'm not that familiar with the innards of alembic yet...
Maybe there are some easy tweaks you can make to simplify my proposed tests?
well im starting to use mock.Mock() and similar to just test the functions in isolation more and more. the test_autogenerate tests are horrible, i hate working with them. I see you used mock, great, maybe the part where it's comparing strings we can skip that , instead just compare the _produce_net_changes() outputs ? if you look at test_diffs and others, you can see that. it only needs to compare the parts that are sensitive to what you're testing.
I still don't really like the way self.context._user_compare_type = my_compare_type is uses the internals of the MigrationContext, but otherwise I would need to duplicate most of the the AutogenTest-setup. If you want I could extract the value of compare_type into a separate classmethod that I can override in the test case, but my feeling is that is it a bit overkill and wouldn't improve the readability of the tests.