有人知道如何模拟正则表达式吗?或者如何使以下代码起作用:
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