В PyTest как настроить плагин CaptureManager: ошибка «У объекта CaptureManager нет атрибута« suspendcapture » - PullRequest
0 голосов
/ 01 июня 2018

У меня есть следующая функция, вызванная из pytest.

def ask_user_input(msg=''):
    """ Asks user to check something manually and answer a question """
    notification = "\n\n???\tANSWER NEEDED\t???\n\n{}".format(msg)

    # suspend input capture by py.test so user input can be recorded here
    capture_manager = pytest.config.pluginmanager.getplugin('capturemanager')
    capture_manager.suspendcapture(in_=True)

    answer = input(notification)

    # resume capture after question have been asked
    capture_manager.resumecapture()

    logging.debug("Answer: {}".format(answer))
    return answer

Однако я получаю следующую ошибку: Ошибка: AttributeError: у объекта 'CaptureManager' нет атрибута 'suspendcapture'

Я использую Python 3.6+.Как я могу использовать CaptureManager как pytest.config в приведенном выше примере, кажется, больше не существует.

1 Ответ

0 голосов
/ 01 июня 2018

Объект 'CaptureManager' не имеет атрибута 'suspendcapture'

Это правда.Методы теперь называются "global" : start_global_capturing, stop_global_capturing, resume_global_capture, suspend_global_capture, ``.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...