testflows / TestFlows-Snapshots

TestFlows.com Open-Source Software Testing Framework's module for working with snapshots.
Other
0 stars 0 forks source link

Add support to clean values before comparison #1

Open vzakaznikov opened 2 hours ago

vzakaznikov commented 2 hours ago

Add support to clean values before comparison:

import re

# Input strings
snapshot_value = "hello 12345.222"
repr_value = "hello 23434.333"

# Regex pattern to match numbers (both integers and decimals)
pattern = r'\d+(\.\d+)?'

# Remove numbers from both strings
snapshot_stripped = re.sub(pattern, '', snapshot_value)
repr_stripped = re.sub(pattern, '', repr_value)

# Compare the stripped strings
if snapshot_stripped.strip() == repr_stripped.strip():
    print("The strings are equal when ignoring numbers.")
else:
    print("The strings are not equal when ignoring numbers.")
vzakaznikov commented 2 hours ago

Implementation: