def METHOD_NAME(self):
    fn(self)
    warnings = self.flushWarnings()
    # on older Pythons, this warning appears twice, so use collapse it
    if len(warnings) == 2 and warnings[0] == warnings[1]:
        del warnings[1]
    self.assertEqual(len(warnings), 1, f"got: {repr(warnings)}")
    self.assertEqual(warnings[0]['category'], DeprecatedApiWarning)