I'm getting AttributeError: 'NoneType' object has no attribute 'group'
mymodule_test.py
import unittest
from unittest import TestCase
from mymodule import get_percentage
class GetCardsTestCase(TestCase):
def test_get_percentage(self):
s = "92 (1%)"
expected = 1
actual = get_percentage(s)
self.assertEqual(actual, expected)
if __name__ == '__main__':
unittest.main()
mymodule.py
import re
def get_percentage(s: str) -> int:
return int(re.match(r'\(([0-9]*)%\)', s).group(1))