from mock import patch

from turbodbc.cursor import _has_numpy_support


def test_has_numpy_support_fails():
    with patch('__builtin__.__import__', side_effect=ImportError):
        assert _has_numpy_support() == False

def test_has_numpy_support_succeeds():
    assert _has_numpy_support() == True
import six

from mock import patch

from turbodbc.cursor import _has_numpy_support


# Python 2/3 compatibility
_IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__)


def test_has_numpy_support_fails():
    with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError):
        assert _has_numpy_support() == False


def test_has_numpy_support_succeeds():
    assert _has_numpy_support() == True
Fix test issue with mocking import for Python 3
Fix test issue with mocking import for Python 3

+ import six
+ 
  from mock import patch
  
  from turbodbc.cursor import _has_numpy_support
  
  
+ # Python 2/3 compatibility
+ _IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__)
+ 
+ 
  def test_has_numpy_support_fails():
-     with patch('__builtin__.__import__', side_effect=ImportError):
+     with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError):
          assert _has_numpy_support() == False
+ 
  
  def test_has_numpy_support_succeeds():
      assert _has_numpy_support() == True
Fix test issue with mocking import for Python 3
## Code Before:
from mock import patch

from turbodbc.cursor import _has_numpy_support


def test_has_numpy_support_fails():
    with patch('__builtin__.__import__', side_effect=ImportError):
        assert _has_numpy_support() == False

def test_has_numpy_support_succeeds():
    assert _has_numpy_support() == True
## Instruction:
Fix test issue with mocking import for Python 3
## Code After:
import six

from mock import patch

from turbodbc.cursor import _has_numpy_support


# Python 2/3 compatibility
_IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__)


def test_has_numpy_support_fails():
    with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError):
        assert _has_numpy_support() == False


def test_has_numpy_support_succeeds():
    assert _has_numpy_support() == True