import unittest

from nose.tools import eq_

# Test that __all__ is sufficient:
from pyelasticsearch import *


class ElasticSearchTestCase(unittest.TestCase):
    def setUp(self):
        self.conn = ElasticSearch()

    def tearDown(self):
        try:
            self.conn.delete_index('test-index')
        except Exception:
            pass

    def assert_result_contains(self, result, expected):
        for (key, value) in expected.items():
            eq_(value, result[key])
        return True

from time import sleep
from unittest import TestCase

from nose import SkipTest
from nose.tools import eq_
from six.moves import xrange

# Test that __all__ is sufficient:
from pyelasticsearch import *


def setUp():
    """When loading the test package, wait for ES to come up."""
    for _ in xrange(200):
        try:
            ElasticSearch().health(wait_for_status='yellow')
            return
        except ConnectionError:
            sleep(.1)
    raise SkipTest('Could not connect to the ES server.')


class ElasticSearchTestCase(TestCase):
    def setUp(self):
        self.conn = ElasticSearch()

    def tearDown(self):
        try:
            self.conn.delete_index('test-index')
        except Exception:
            pass

    def assert_result_contains(self, result, expected):
        for (key, value) in expected.items():
            eq_(value, result[key])
        return True

Add a wait to see if we can get Travis passing again.
Add a wait to see if we can get Travis passing again.

- import unittest
+ from time import sleep
+ from unittest import TestCase
  
+ from nose import SkipTest
  from nose.tools import eq_
+ from six.moves import xrange
  
  # Test that __all__ is sufficient:
  from pyelasticsearch import *
  
  
+ def setUp():
+     """When loading the test package, wait for ES to come up."""
+     for _ in xrange(200):
+         try:
+             ElasticSearch().health(wait_for_status='yellow')
+             return
+         except ConnectionError:
+             sleep(.1)
+     raise SkipTest('Could not connect to the ES server.')
+ 
+ 
- class ElasticSearchTestCase(unittest.TestCase):
+ class ElasticSearchTestCase(TestCase):
      def setUp(self):
          self.conn = ElasticSearch()
  
      def tearDown(self):
          try:
              self.conn.delete_index('test-index')
          except Exception:
              pass
  
      def assert_result_contains(self, result, expected):
          for (key, value) in expected.items():
              eq_(value, result[key])
          return True
  
Add a wait to see if we can get Travis passing again.
## Code Before:
import unittest

from nose.tools import eq_

# Test that __all__ is sufficient:
from pyelasticsearch import *


class ElasticSearchTestCase(unittest.TestCase):
    def setUp(self):
        self.conn = ElasticSearch()

    def tearDown(self):
        try:
            self.conn.delete_index('test-index')
        except Exception:
            pass

    def assert_result_contains(self, result, expected):
        for (key, value) in expected.items():
            eq_(value, result[key])
        return True

## Instruction:
Add a wait to see if we can get Travis passing again.
## Code After:
from time import sleep
from unittest import TestCase

from nose import SkipTest
from nose.tools import eq_
from six.moves import xrange

# Test that __all__ is sufficient:
from pyelasticsearch import *


def setUp():
    """When loading the test package, wait for ES to come up."""
    for _ in xrange(200):
        try:
            ElasticSearch().health(wait_for_status='yellow')
            return
        except ConnectionError:
            sleep(.1)
    raise SkipTest('Could not connect to the ES server.')


class ElasticSearchTestCase(TestCase):
    def setUp(self):
        self.conn = ElasticSearch()

    def tearDown(self):
        try:
            self.conn.delete_index('test-index')
        except Exception:
            pass

    def assert_result_contains(self, result, expected):
        for (key, value) in expected.items():
            eq_(value, result[key])
        return True
