Python Mocking - Как издеваться над регулярными выражениями - PullRequest
0 голосов
/ 07 ноября 2018

Кто-нибудь знает, как издеваться над регулярными выражениями? Или как заставить работать следующий код:

a.py

import re

def get_number_from_string():
    string = '3 monkies, 6 apes'
    string_split = string.split(',')

    fetch_number = re.match('[0-9]+', string_split[0])
    number = fetch_number.group(0)

    return number

test_a.py

import pytest
import a

def test_get_number_from_string():

    #with patch(somehow patch the re expression parts to return the int 10):

        number = a.get_number_from_string()

     assert number == 10
...