'The backend doesn\'t store an unlimited number of queries (#12581).'

@skipUnlessDBFeature('test_db_allows_multiple_connections')
@override_settings(DEBUG=True)
def test_queries_limit(self):

    old_queries_limit = BaseDatabaseWrapper.queries_limit
    BaseDatabaseWrapper.queries_limit = 3
    new_connection = connection.copy()
    with new_connection.cursor():
        pass
    new_connection.queries_log.clear()
    try:
        with new_connection.cursor() as cursor:
            cursor.execute(('SELECT    1' + new_connection.features.bare_select_suffix))
            cursor.execute(('SELECT    2' + new_connection.features.bare_select_suffix))
        with warnings.catch_warnings(record=True) as w:
            self.assertEqual(2, len(new_connection.queries))
            self.assertEqual(0, len(w))
        with new_connection.cursor() as cursor:
            cursor.execute(('SELECT    3' + new_connection.features.bare_select_suffix))
            cursor.execute(('SELECT    4' + new_connection.features.bare_select_suffix))
        with warnings.catch_warnings(record=True) as w:
            self.assertEqual(3, len(new_connection.queries))
            self.assertEqual(1, len(w))
            self.assertEqual(str(w[0].message), 'Limit    for    query    logging    exceeded,    only    the    last    3    queries    will    be    returned.')
    finally:
        BaseDatabaseWrapper.queries_limit = old_queries_limit
        new_connection.close()
