from unittest.mock import patch

from flask import Flask
from flask_assistant import Assistant
from flask_assistant.response import _Response


@patch('flask_assistant.response.current_app')
def test_response_with_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foobar')
    assert resp._response['speech'] == 'foobar'


@patch('flask_assistant.response.current_app')
def test_response_with_None_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response(None)
    assert resp._response['speech'] is None


@patch('flask_assistant.response.current_app')
def test_response_speech_escaping(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foo & bar')
    assert resp._response['speech'] == 'foo &amp; bar'

from flask import Flask
from flask_assistant import Assistant
from flask_assistant.response import _Response
import pytest

patch = pytest.importorskip('unittest.mock.patch')


@patch('flask_assistant.response.current_app')
def test_response_with_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foobar')
    assert resp._response['speech'] == 'foobar'


@patch('flask_assistant.response.current_app')
def test_response_with_None_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response(None)
    assert resp._response['speech'] is None


@patch('flask_assistant.response.current_app')
def test_response_speech_escaping(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foo & bar')
    assert resp._response['speech'] == 'foo &amp; bar'

Disable test for py27 (mock not available)
Disable test for py27 (mock not available)

- from unittest.mock import patch
- 
  from flask import Flask
  from flask_assistant import Assistant
  from flask_assistant.response import _Response
+ import pytest
+ 
+ patch = pytest.importorskip('unittest.mock.patch')
  
  
  @patch('flask_assistant.response.current_app')
  def test_response_with_speech(mock):
      mock = Assistant(Flask(__name__))
      resp = _Response('foobar')
      assert resp._response['speech'] == 'foobar'
  
  
  @patch('flask_assistant.response.current_app')
  def test_response_with_None_speech(mock):
      mock = Assistant(Flask(__name__))
      resp = _Response(None)
      assert resp._response['speech'] is None
  
  
  @patch('flask_assistant.response.current_app')
  def test_response_speech_escaping(mock):
      mock = Assistant(Flask(__name__))
      resp = _Response('foo & bar')
      assert resp._response['speech'] == 'foo &amp; bar'
  
Disable test for py27 (mock not available)
## Code Before:
from unittest.mock import patch

from flask import Flask
from flask_assistant import Assistant
from flask_assistant.response import _Response


@patch('flask_assistant.response.current_app')
def test_response_with_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foobar')
    assert resp._response['speech'] == 'foobar'


@patch('flask_assistant.response.current_app')
def test_response_with_None_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response(None)
    assert resp._response['speech'] is None


@patch('flask_assistant.response.current_app')
def test_response_speech_escaping(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foo & bar')
    assert resp._response['speech'] == 'foo &amp; bar'

## Instruction:
Disable test for py27 (mock not available)
## Code After:
from flask import Flask
from flask_assistant import Assistant
from flask_assistant.response import _Response
import pytest

patch = pytest.importorskip('unittest.mock.patch')


@patch('flask_assistant.response.current_app')
def test_response_with_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foobar')
    assert resp._response['speech'] == 'foobar'


@patch('flask_assistant.response.current_app')
def test_response_with_None_speech(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response(None)
    assert resp._response['speech'] is None


@patch('flask_assistant.response.current_app')
def test_response_speech_escaping(mock):
    mock = Assistant(Flask(__name__))
    resp = _Response('foo & bar')
    assert resp._response['speech'] == 'foo &amp; bar'
