from unittest.mock import Mock


def create_mock_Popen(x_success='', x_error=''):
    """Return mock subprocess.Popen class.

    stdout and stderr will be returned by communicate() of its returned
    instance.
    """
    mock_Popen_instance = Mock()
    mock_Popen_instance.communicate = Mock(return_value=(x_success, x_error))
    mock_Popen = Mock(return_value=mock_Popen_instance)
    return mock_Popen