diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index fd293f69e6..fce2a011c2 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -125,10 +125,10 @@ def normalize_fixture_data(decorated_function: CallableT, keep: List[str]=[]) -> } # We'll replace "invoice_prefix": "A35BC4Q" with something like "invoice_prefix": "NORMA01" pattern_translations.update({ - '"invoice_prefix": "[A-Za-z0-9]{7}"': '"invoice_prefix": "NORMA%02d"', - '"fingerprint": "[A-Za-z0-9]{16}"': '"fingerprint": "NORMALIZED%06d"', - '"number": "[A-Za-z0-9]{7}-[A-Za-z0-9]{4}"': '"number": "NORMALI-%04d"', - '"address": "[A-Za-z0-9]{9}-test_[A-Za-z0-9]{12}"': '"address": "000000000-test_NORMALIZED%02d"', + '"invoice_prefix": "([A-Za-z0-9]{7})"': 'NORMA%02d', + '"fingerprint": "([A-Za-z0-9]{16})"': 'NORMALIZED%06d', + '"number": "([A-Za-z0-9]{7}-[A-Za-z0-9]{4})"': 'NORMALI-%04d', + '"address": "([A-Za-z0-9]{9}-test_[A-Za-z0-9]{12})"': '000000000-test_NORMALIZED%02d', # Does not preserve relative ordering of the timestamps, nor any # coordination with the timestamps in setUp mocks (e.g. Plan.created). ': (1[5-9][0-9]{8})(?![0-9-])': '1%09d', @@ -144,8 +144,8 @@ def normalize_fixture_data(decorated_function: CallableT, keep: List[str]=[]) -> if match not in normalized_values[pattern]: normalized_values[pattern][match] = translation % (len(normalized_values[pattern]) + 1,) file_content = file_content.replace(match, normalized_values[pattern][match]) - file_content = re.sub(r'"risk_score": \d+', '"risk_score": 00', file_content) - file_content = re.sub(r'"times_redeemed": \d+', '"times_redeemed": 00', file_content) + file_content = re.sub(r'(?<="risk_score": )(\d+)', '00', file_content) + file_content = re.sub(r'(?<="times_redeemed": )(\d+)', '00', file_content) # Dates file_content = re.sub(r'[0-3]\d [A-Z][a-z]{2} 20[1-2]\d', 'NORMALIZED DATE', file_content) # IP addresses