Exemplo n.º 1
0
    def test_empty_warnings(self):
        con = Connection()
        with warnings.catch_warnings(record=True) as w:
            con._raise_warnings(())
            con._raise_warnings([])

        self.assertEqual(w, [])
Exemplo n.º 2
0
    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"])
Exemplo n.º 3
0
    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"],
        )