Skip to content

Commit

Permalink
Fixed #471
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Jul 15, 2024
1 parent cfbe694 commit e71627d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions peppy/simple_attr_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def __getattr__(self, item):
except KeyError:
raise AttributeError(f"Attribute not found: {item}")

def __eq__(self, other: "SimpleAttMap"):
return self._mapped_attr == other._mapped_attr

@property
def attributes(self):
return self._mapped_attr
21 changes: 21 additions & 0 deletions tests/smoketests/test_Sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,24 @@ def test_pickle_in_samples(self, example_pep_cfg_path):
unpickled_sample = pickle.loads(pickled_data)

assert sample.to_dict() == unpickled_sample.to_dict()

@pytest.mark.parametrize("example_pep_cfg_path", ["basic"], indirect=True)
def test_equals_samples(self, example_pep_cfg_path):
p1 = Project(cfg=example_pep_cfg_path)
p2 = Project(cfg=example_pep_cfg_path)
s1 = p1.samples[0]
s2 = p2.samples[0]

assert s1 == s2

@pytest.mark.parametrize("example_pep_cfg_path", ["basic"], indirect=True)
def test_not_equals_samples(self, example_pep_cfg_path):
p1 = Project(cfg=example_pep_cfg_path)
p2 = Project(cfg=example_pep_cfg_path)
s1 = p1.samples[0]
s2 = p2.samples[0]
s3 = p2.samples[1]

s2.new = "something"
assert not s1 == s2
assert not s1 == s3

0 comments on commit e71627d

Please sign in to comment.