def test_empty_warnings(self): con = Connection() with warnings.catch_warnings(record=True) as w: con._raise_warnings(()) con._raise_warnings([]) self.assertEqual(w, [])
def test_raises_warnings_when_folded(self): con = Connection() with warnings.catch_warnings(record=True) as warn: con._raise_warnings([ '299 Elasticsearch-7.6.1-aa751 "warning",' '299 Elasticsearch-7.6.1-aa751 "folded"', ]) self.assertEqual([str(w.message) for w in warn], ["warning", "folded"])
def test_raises_warnings(self): con = Connection() with warnings.catch_warnings(record=True) as warn: con._raise_warnings( ['299 Elasticsearch-7.6.1-aa751 "this is deprecated"']) self.assertEqual([str(w.message) for w in warn], ["this is deprecated"]) with warnings.catch_warnings(record=True) as warn: con._raise_warnings([ '299 Elasticsearch-7.6.1-aa751 "this is also deprecated"', '299 Elasticsearch-7.6.1-aa751 "this is also deprecated"', '299 Elasticsearch-7.6.1-aa751 "guess what? deprecated"', ]) self.assertEqual( [str(w.message) for w in warn], ["this is also deprecated", "guess what? deprecated"], )