MAINT: use assert_warns instead of a more complicated mechanism