2023-12-30 02:37:49 +00:00
|
|
|
import datetime
|
2024-02-07 18:58:52 +00:00
|
|
|
import decimal
|
2024-02-13 01:35:21 +00:00
|
|
|
import pytest
|
2024-01-03 00:55:24 +00:00
|
|
|
|
2023-12-30 02:37:49 +00:00
|
|
|
from codeflash.verification.comparator import comparator
|
|
|
|
|
from codeflash.verification.equivalence import compare_results
|
|
|
|
|
from codeflash.verification.test_results import (
|
|
|
|
|
TestResults,
|
|
|
|
|
FunctionTestInvocation,
|
|
|
|
|
InvocationId,
|
|
|
|
|
TestType,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_basic_python_objects():
|
|
|
|
|
a = 5
|
|
|
|
|
b = 5
|
|
|
|
|
c = 6
|
|
|
|
|
d = None
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
assert not comparator(a, d)
|
|
|
|
|
|
|
|
|
|
a = 5.0
|
|
|
|
|
b = 5.0
|
|
|
|
|
c = 6.0
|
|
|
|
|
d = None
|
|
|
|
|
e = None
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
assert not comparator(a, d)
|
|
|
|
|
assert not comparator(d, a)
|
|
|
|
|
assert comparator(d, e)
|
|
|
|
|
|
|
|
|
|
a = "Hello"
|
|
|
|
|
b = "Hello"
|
|
|
|
|
c = "World"
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
|
|
|
|
a = [1, 2, 3]
|
|
|
|
|
b = [1, 2, 3]
|
|
|
|
|
c = [1, 2, 4]
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
|
|
|
|
a = {"a": 1, "b": 2}
|
|
|
|
|
b = {"a": 1, "b": 2}
|
|
|
|
|
c = {"a": 1, "b": 3}
|
|
|
|
|
d = {"c": 1, "b": 2}
|
2024-02-06 21:46:54 +00:00
|
|
|
e = {"a": 1, "b": 2, "c": 3}
|
2023-12-30 02:37:49 +00:00
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
assert not comparator(a, d)
|
2024-02-06 21:46:54 +00:00
|
|
|
assert not comparator(a, e)
|
2023-12-30 02:37:49 +00:00
|
|
|
|
|
|
|
|
a = (1, 2, "str")
|
|
|
|
|
b = (1, 2, "str")
|
|
|
|
|
c = (1, 2, "str2")
|
|
|
|
|
d = [1, 2, "str"]
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
assert not comparator(a, d)
|
|
|
|
|
|
2024-02-13 01:35:21 +00:00
|
|
|
a = {1, 2, 3}
|
|
|
|
|
b = {2, 3, 1}
|
|
|
|
|
c = {1, 2, 4}
|
|
|
|
|
d = {1, 2, 3, 4}
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
assert not comparator(a, d)
|
|
|
|
|
|
2023-12-30 02:37:49 +00:00
|
|
|
|
|
|
|
|
def test_standard_python_library_objects():
|
|
|
|
|
a = datetime.datetime(2020, 2, 2, 2, 2, 2)
|
|
|
|
|
b = datetime.datetime(2020, 2, 2, 2, 2, 2)
|
|
|
|
|
c = datetime.datetime(2020, 2, 2, 2, 2, 3)
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
|
|
|
|
a = datetime.date(2020, 2, 2)
|
|
|
|
|
b = datetime.date(2020, 2, 2)
|
|
|
|
|
c = datetime.date(2020, 2, 3)
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
|
|
|
|
a = datetime.timedelta(days=1)
|
|
|
|
|
b = datetime.timedelta(days=1)
|
|
|
|
|
c = datetime.timedelta(days=2)
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
2024-02-07 18:58:52 +00:00
|
|
|
a = decimal.Decimal(3.14)
|
|
|
|
|
b = decimal.Decimal(3.14)
|
|
|
|
|
c = decimal.Decimal(3.15)
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
2023-12-30 02:37:49 +00:00
|
|
|
|
|
|
|
|
def test_numpy():
|
|
|
|
|
try:
|
|
|
|
|
import numpy as np
|
|
|
|
|
except ImportError:
|
|
|
|
|
pytest.skip()
|
|
|
|
|
a = np.array([1, 2, 3])
|
|
|
|
|
b = np.array([1, 2, 3])
|
|
|
|
|
c = np.array([1, 2, 4])
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
|
|
|
|
d = np.array([[1, 2], [3, 4]])
|
|
|
|
|
e = np.array([[1, 2], [3, 4]])
|
|
|
|
|
f = np.array([[1, 2], [3, 5]])
|
|
|
|
|
assert comparator(d, e)
|
|
|
|
|
assert not comparator(d, f)
|
|
|
|
|
assert not comparator(a, d)
|
|
|
|
|
|
|
|
|
|
g = np.array([1.0, 2.0, 3.0])
|
|
|
|
|
assert not comparator(a, g)
|
|
|
|
|
|
|
|
|
|
h = np.float32(1.0)
|
|
|
|
|
i = np.float32(1.0)
|
|
|
|
|
assert comparator(h, i)
|
|
|
|
|
|
|
|
|
|
j = np.float64(1.0)
|
|
|
|
|
k = np.float64(1.0)
|
|
|
|
|
assert not comparator(h, j)
|
|
|
|
|
print(comparator(j, k))
|
|
|
|
|
assert comparator(j, k)
|
|
|
|
|
|
|
|
|
|
l = np.int32(1)
|
|
|
|
|
m = np.int32(1)
|
|
|
|
|
assert comparator(l, m)
|
|
|
|
|
assert not comparator(l, h)
|
|
|
|
|
assert not comparator(l, j)
|
|
|
|
|
|
|
|
|
|
n = np.int64(1)
|
|
|
|
|
o = np.int64(1)
|
|
|
|
|
assert not comparator(n, l)
|
|
|
|
|
assert comparator(n, o)
|
|
|
|
|
|
|
|
|
|
p = np.uint32(1)
|
|
|
|
|
q = np.uint32(1)
|
|
|
|
|
assert comparator(p, q)
|
|
|
|
|
assert not comparator(p, l)
|
|
|
|
|
|
|
|
|
|
r = np.uint64(1)
|
|
|
|
|
s = np.uint64(1)
|
|
|
|
|
assert not comparator(r, p)
|
|
|
|
|
assert comparator(r, s)
|
|
|
|
|
|
|
|
|
|
t = np.bool_(True)
|
|
|
|
|
u = np.bool_(True)
|
|
|
|
|
assert comparator(t, u)
|
|
|
|
|
assert not comparator(t, r)
|
|
|
|
|
|
|
|
|
|
v = np.complex64(1.0 + 1.0j)
|
|
|
|
|
w = np.complex64(1.0 + 1.0j)
|
|
|
|
|
assert comparator(v, w)
|
|
|
|
|
assert not comparator(v, t)
|
|
|
|
|
|
|
|
|
|
x = np.complex128(1.0 + 1.0j)
|
|
|
|
|
y = np.complex128(1.0 + 1.0j)
|
|
|
|
|
assert not comparator(x, v)
|
|
|
|
|
assert comparator(x, y)
|
|
|
|
|
|
|
|
|
|
# Create numpy array with mixed type object
|
|
|
|
|
z = np.array([1, 2, "str"], dtype=np.object_)
|
|
|
|
|
aa = np.array([1, 2, "str"], dtype=np.object_)
|
|
|
|
|
ab = np.array([1, 2, "str2"], dtype=np.object_)
|
|
|
|
|
assert comparator(z, aa)
|
|
|
|
|
assert not comparator(z, ab)
|
|
|
|
|
|
|
|
|
|
ac = np.array([1, 2, "str2"])
|
|
|
|
|
ad = np.array([1, 2, "str2"])
|
|
|
|
|
assert comparator(ac, ad)
|
|
|
|
|
|
2024-02-07 02:25:24 +00:00
|
|
|
# Test for numpy array with nan and inf
|
|
|
|
|
ae = np.array([1, 2, np.nan])
|
|
|
|
|
af = np.array([1, 2, np.nan])
|
|
|
|
|
ag = np.array([1, 2, np.inf])
|
|
|
|
|
ah = np.array([1, 2, np.inf])
|
|
|
|
|
ai = np.inf
|
|
|
|
|
aj = np.inf
|
|
|
|
|
ak = np.nan
|
|
|
|
|
al = np.nan
|
|
|
|
|
assert comparator(ae, af)
|
|
|
|
|
assert comparator(ag, ah)
|
|
|
|
|
assert not comparator(ae, ag)
|
|
|
|
|
assert not comparator(af, ah)
|
|
|
|
|
assert comparator(ai, aj)
|
|
|
|
|
assert comparator(ak, al)
|
|
|
|
|
assert not comparator(ai, ak)
|
|
|
|
|
|
2023-12-30 02:37:49 +00:00
|
|
|
|
2024-02-06 21:46:54 +00:00
|
|
|
def test_scipy():
|
|
|
|
|
try:
|
|
|
|
|
import scipy as sp
|
|
|
|
|
except ImportError:
|
|
|
|
|
pytest.skip()
|
|
|
|
|
a = sp.sparse.csr_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
b = sp.sparse.csr_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
c = sp.sparse.csr_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 6]])
|
2024-02-07 02:25:24 +00:00
|
|
|
ca = sp.sparse.csr_matrix([[1, 0, 0, 0], [0, 0, 3, 0], [4, 0, 6, 0]])
|
2024-02-06 21:46:54 +00:00
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
2024-02-07 02:25:24 +00:00
|
|
|
assert not comparator(c, ca)
|
2024-02-06 21:46:54 +00:00
|
|
|
|
|
|
|
|
d = sp.sparse.csc_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
e = sp.sparse.csc_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
f = sp.sparse.csc_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 6]])
|
2024-02-07 02:25:24 +00:00
|
|
|
fa = sp.sparse.csc_matrix([[1, 0, 0, 0], [0, 0, 3, 0], [4, 0, 6, 0]])
|
2024-02-06 21:46:54 +00:00
|
|
|
assert comparator(d, e)
|
|
|
|
|
assert not comparator(d, f)
|
|
|
|
|
assert not comparator(a, d)
|
2024-02-07 02:25:24 +00:00
|
|
|
assert not comparator(c, f)
|
|
|
|
|
assert not comparator(f, fa)
|
2024-02-06 21:46:54 +00:00
|
|
|
|
|
|
|
|
g = sp.sparse.lil_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
h = sp.sparse.lil_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
i = sp.sparse.lil_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 6]])
|
|
|
|
|
assert comparator(g, h)
|
|
|
|
|
assert not comparator(g, i)
|
|
|
|
|
assert not comparator(a, g)
|
|
|
|
|
|
|
|
|
|
j = sp.sparse.dok_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
k = sp.sparse.dok_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
l = sp.sparse.dok_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 6]])
|
|
|
|
|
assert comparator(j, k)
|
|
|
|
|
assert not comparator(j, l)
|
|
|
|
|
assert not comparator(a, j)
|
|
|
|
|
|
|
|
|
|
m = sp.sparse.dia_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
n = sp.sparse.dia_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
o = sp.sparse.dia_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 6]])
|
|
|
|
|
assert comparator(m, n)
|
|
|
|
|
assert not comparator(m, o)
|
|
|
|
|
assert not comparator(a, m)
|
|
|
|
|
|
|
|
|
|
p = sp.sparse.coo_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
q = sp.sparse.coo_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
r = sp.sparse.coo_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 6]])
|
|
|
|
|
assert comparator(p, q)
|
|
|
|
|
assert not comparator(p, r)
|
|
|
|
|
assert not comparator(a, p)
|
|
|
|
|
|
|
|
|
|
s = sp.sparse.bsr_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
t = sp.sparse.bsr_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 5]])
|
|
|
|
|
u = sp.sparse.bsr_matrix([[1, 0, 0], [0, 0, 3], [4, 0, 6]])
|
|
|
|
|
assert comparator(s, t)
|
|
|
|
|
assert not comparator(s, u)
|
|
|
|
|
assert not comparator(a, s)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
row = np.array([0, 3, 1, 0])
|
|
|
|
|
col = np.array([0, 3, 1, 2])
|
|
|
|
|
data = np.array([4, 5, 7, 9])
|
|
|
|
|
v = sp.sparse.coo_array((data, (row, col)), shape=(4, 4)).toarray()
|
|
|
|
|
w = sp.sparse.coo_array((data, (row, col)), shape=(4, 4)).toarray()
|
|
|
|
|
assert comparator(v, w)
|
|
|
|
|
except ImportError:
|
|
|
|
|
print("Should run tests with numpy installed to test more thoroughly")
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2024-02-07 02:25:24 +00:00
|
|
|
def test_pandas():
|
|
|
|
|
try:
|
|
|
|
|
import pandas as pd
|
|
|
|
|
except ImportError:
|
|
|
|
|
pytest.skip()
|
|
|
|
|
a = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
|
|
|
|
|
b = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
|
|
|
|
|
c = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 7]})
|
|
|
|
|
ca = pd.DataFrame({"a": [1, 2, 3, 4], "b": [4, 5, 6, 7]})
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
assert not comparator(c, ca)
|
|
|
|
|
|
|
|
|
|
ak = pd.DataFrame(
|
|
|
|
|
{
|
|
|
|
|
"a": [datetime.datetime(2020, 2, 2, 2, 2, 2), datetime.datetime(2020, 2, 2, 2, 2, 2)],
|
|
|
|
|
"b": [4, 5],
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
al = pd.DataFrame(
|
|
|
|
|
{
|
|
|
|
|
"a": [datetime.datetime(2020, 2, 2, 2, 2, 2), datetime.datetime(2020, 2, 2, 2, 2, 2)],
|
|
|
|
|
"b": [4, 5],
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
am = pd.DataFrame(
|
|
|
|
|
{
|
|
|
|
|
"a": [datetime.datetime(2020, 2, 2, 2, 2, 2), datetime.datetime(2020, 2, 2, 2, 2, 3)],
|
|
|
|
|
"b": [4, 5],
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
assert comparator(ak, al)
|
|
|
|
|
assert not comparator(ak, am)
|
|
|
|
|
|
|
|
|
|
d = pd.Series([1, 2, 3])
|
|
|
|
|
e = pd.Series([1, 2, 3])
|
|
|
|
|
f = pd.Series([1, 2, 4])
|
|
|
|
|
assert comparator(d, e)
|
|
|
|
|
assert not comparator(d, f)
|
|
|
|
|
|
|
|
|
|
g = pd.Index([1, 2, 3])
|
|
|
|
|
h = pd.Index([1, 2, 3])
|
|
|
|
|
i = pd.Index([1, 2, 4])
|
|
|
|
|
assert comparator(g, h)
|
|
|
|
|
assert not comparator(g, i)
|
|
|
|
|
|
|
|
|
|
j = pd.MultiIndex.from_tuples([(1, 2), (3, 4)])
|
|
|
|
|
k = pd.MultiIndex.from_tuples([(1, 2), (3, 4)])
|
|
|
|
|
l = pd.MultiIndex.from_tuples([(1, 2), (3, 5)])
|
|
|
|
|
assert comparator(j, k)
|
|
|
|
|
assert not comparator(j, l)
|
|
|
|
|
|
|
|
|
|
m = pd.Categorical([1, 2, 3])
|
|
|
|
|
n = pd.Categorical([1, 2, 3])
|
|
|
|
|
o = pd.Categorical([1, 2, 4])
|
|
|
|
|
assert comparator(m, n)
|
|
|
|
|
assert not comparator(m, o)
|
|
|
|
|
|
|
|
|
|
p = pd.Interval(1, 2)
|
|
|
|
|
q = pd.Interval(1, 2)
|
|
|
|
|
r = pd.Interval(1, 3)
|
|
|
|
|
assert comparator(p, q)
|
|
|
|
|
assert not comparator(p, r)
|
|
|
|
|
|
|
|
|
|
s = pd.IntervalIndex.from_tuples([(1, 2), (3, 4)])
|
|
|
|
|
t = pd.IntervalIndex.from_tuples([(1, 2), (3, 4)])
|
|
|
|
|
u = pd.IntervalIndex.from_tuples([(1, 2), (3, 5)])
|
|
|
|
|
assert comparator(s, t)
|
|
|
|
|
assert not comparator(s, u)
|
|
|
|
|
|
|
|
|
|
v = pd.Period("2021-01")
|
|
|
|
|
w = pd.Period("2021-01")
|
|
|
|
|
x = pd.Period("2021-02")
|
|
|
|
|
assert comparator(v, w)
|
|
|
|
|
assert not comparator(v, x)
|
|
|
|
|
|
|
|
|
|
y = pd.period_range(start="2021-01", periods=3, freq="M")
|
|
|
|
|
z = pd.period_range(start="2021-01", periods=3, freq="M")
|
|
|
|
|
aa = pd.period_range(start="2021-01", periods=4, freq="M")
|
|
|
|
|
assert comparator(y, z)
|
|
|
|
|
assert not comparator(y, aa)
|
|
|
|
|
|
|
|
|
|
ab = pd.Timedelta("1 days")
|
|
|
|
|
ac = pd.Timedelta("1 days")
|
|
|
|
|
ad = pd.Timedelta("2 days")
|
|
|
|
|
assert comparator(ab, ac)
|
|
|
|
|
assert not comparator(ab, ad)
|
|
|
|
|
|
|
|
|
|
ae = pd.TimedeltaIndex(["1 days", "2 days"])
|
|
|
|
|
af = pd.TimedeltaIndex(["1 days", "2 days"])
|
|
|
|
|
ag = pd.TimedeltaIndex(["1 days", "3 days"])
|
|
|
|
|
assert comparator(ae, af)
|
|
|
|
|
assert not comparator(ae, ag)
|
|
|
|
|
|
|
|
|
|
ah = pd.Timestamp("2021-01-01")
|
|
|
|
|
ai = pd.Timestamp("2021-01-01")
|
|
|
|
|
aj = pd.Timestamp("2021-01-02")
|
|
|
|
|
assert comparator(ah, ai)
|
|
|
|
|
assert not comparator(ah, aj)
|
|
|
|
|
|
|
|
|
|
# test cases for sparse pandas arrays
|
|
|
|
|
an = pd.arrays.SparseArray([1, 2, 3])
|
|
|
|
|
ao = pd.arrays.SparseArray([1, 2, 3])
|
|
|
|
|
ap = pd.arrays.SparseArray([1, 2, 4])
|
|
|
|
|
assert comparator(an, ao)
|
|
|
|
|
assert not comparator(an, ap)
|
|
|
|
|
|
|
|
|
|
|
2023-12-30 02:37:49 +00:00
|
|
|
def test_custom_object():
|
|
|
|
|
class TestClass:
|
|
|
|
|
def __init__(self, value):
|
|
|
|
|
self.value = value
|
|
|
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
|
return self.value == other.value
|
|
|
|
|
|
|
|
|
|
a = TestClass(5)
|
|
|
|
|
b = TestClass(5)
|
|
|
|
|
c = TestClass(6)
|
|
|
|
|
assert comparator(a, b)
|
|
|
|
|
assert not comparator(a, c)
|
|
|
|
|
|
|
|
|
|
class TestClass2:
|
|
|
|
|
def __init__(self, value):
|
|
|
|
|
self.value = value
|
|
|
|
|
|
|
|
|
|
a = TestClass(5)
|
|
|
|
|
b = TestClass2(5)
|
|
|
|
|
c = TestClass2(5)
|
|
|
|
|
assert not comparator(a, b)
|
|
|
|
|
assert comparator(
|
|
|
|
|
b, c
|
|
|
|
|
) # This is a fallback to True right now since we don't know how to compare them. This can be improved later
|
|
|
|
|
|
|
|
|
|
class TestClass3(TestClass):
|
|
|
|
|
def print(self):
|
|
|
|
|
print(self.value)
|
|
|
|
|
|
|
|
|
|
a = TestClass2(5)
|
|
|
|
|
b = TestClass3(5)
|
|
|
|
|
c = TestClass3(5)
|
|
|
|
|
assert not comparator(a, b)
|
|
|
|
|
assert comparator(b, c)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_compare_results_fn():
|
|
|
|
|
original_results = TestResults(
|
|
|
|
|
[
|
|
|
|
|
FunctionTestInvocation(
|
|
|
|
|
id=InvocationId(
|
|
|
|
|
test_module_path="test_module_path",
|
|
|
|
|
test_class_name="test_class_name",
|
|
|
|
|
test_function_name="test_function_name",
|
|
|
|
|
function_getting_tested="function_getting_tested",
|
|
|
|
|
iteration_id="0",
|
|
|
|
|
),
|
|
|
|
|
file_name="file_name",
|
|
|
|
|
did_pass=True,
|
|
|
|
|
runtime=5,
|
|
|
|
|
test_framework="unittest",
|
|
|
|
|
test_type=TestType.EXISTING_UNIT_TEST,
|
|
|
|
|
return_value=5,
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
new_results_1 = TestResults(
|
|
|
|
|
[
|
|
|
|
|
FunctionTestInvocation(
|
|
|
|
|
id=InvocationId(
|
|
|
|
|
test_module_path="test_module_path",
|
|
|
|
|
test_class_name="test_class_name",
|
|
|
|
|
test_function_name="test_function_name",
|
|
|
|
|
function_getting_tested="function_getting_tested",
|
|
|
|
|
iteration_id="0",
|
|
|
|
|
),
|
|
|
|
|
file_name="file_name",
|
|
|
|
|
did_pass=True,
|
|
|
|
|
runtime=10,
|
|
|
|
|
test_framework="unittest",
|
|
|
|
|
test_type=TestType.EXISTING_UNIT_TEST,
|
|
|
|
|
return_value=5,
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert compare_results(original_results, new_results_1)
|
|
|
|
|
|
|
|
|
|
new_results_2 = TestResults(
|
|
|
|
|
[
|
|
|
|
|
FunctionTestInvocation(
|
|
|
|
|
id=InvocationId(
|
|
|
|
|
test_module_path="test_module_path",
|
|
|
|
|
test_class_name="test_class_name",
|
|
|
|
|
test_function_name="test_function_name",
|
|
|
|
|
function_getting_tested="function_getting_tested",
|
|
|
|
|
iteration_id="0",
|
|
|
|
|
),
|
|
|
|
|
file_name="file_name",
|
|
|
|
|
did_pass=True,
|
|
|
|
|
runtime=10,
|
|
|
|
|
test_framework="unittest",
|
|
|
|
|
test_type=TestType.EXISTING_UNIT_TEST,
|
|
|
|
|
return_value=[5],
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert not compare_results(original_results, new_results_2)
|
|
|
|
|
|
|
|
|
|
new_results_3 = TestResults(
|
|
|
|
|
[
|
|
|
|
|
FunctionTestInvocation(
|
|
|
|
|
id=InvocationId(
|
|
|
|
|
test_module_path="test_module_path",
|
|
|
|
|
test_class_name="test_class_name",
|
|
|
|
|
test_function_name="test_function_name",
|
|
|
|
|
function_getting_tested="function_getting_tested",
|
|
|
|
|
iteration_id="0",
|
|
|
|
|
),
|
|
|
|
|
file_name="file_name",
|
|
|
|
|
did_pass=True,
|
|
|
|
|
runtime=10,
|
|
|
|
|
test_framework="unittest",
|
|
|
|
|
test_type=TestType.EXISTING_UNIT_TEST,
|
|
|
|
|
return_value=5,
|
|
|
|
|
),
|
|
|
|
|
FunctionTestInvocation(
|
|
|
|
|
id=InvocationId(
|
|
|
|
|
test_module_path="test_module_path",
|
|
|
|
|
test_class_name="test_class_name",
|
|
|
|
|
test_function_name="test_function_name",
|
|
|
|
|
function_getting_tested="function_getting_tested",
|
|
|
|
|
iteration_id="2",
|
|
|
|
|
),
|
|
|
|
|
file_name="file_name",
|
|
|
|
|
did_pass=True,
|
|
|
|
|
runtime=10,
|
|
|
|
|
test_framework="unittest",
|
|
|
|
|
test_type=TestType.EXISTING_UNIT_TEST,
|
|
|
|
|
return_value=5,
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert not compare_results(original_results, new_results_3)
|
|
|
|
|
|
|
|
|
|
assert not compare_results(TestResults(), TestResults())
|