Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Mar 9, 2024
1 parent 90255d6 commit 3d660a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyecore/ecore.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def __set__(self, instance, value):
# if value is not previous_value and isinstance(value, ECollection):
# raise AttributeError('Cannot reafect an ECollection with '
# 'another one, even if compatible')
if isinstance(value, Iterable):
if not isinstance(value, str) and isinstance(value, Iterable):
previous_value.clear()
previous_value.extend(value)
return
Expand Down
13 changes: 9 additions & 4 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,18 @@ def test_collection_affectation():
x, y = A(), A()

a = A(name='tes')
with pytest.raises(BadValueError):
x.toa = [a]
# with pytest.raises(BadValueError):
col = x.toa
x.toa = [a]

assert x.toa is col

x.toa.append(a)

with pytest.raises(AttributeError):
y.toa = x.toa
y.toa = x.toa

assert y.toa is not x.toa
assert x.toa[0] in y.toa

b = A()
y.toa += [b]
Expand Down

0 comments on commit 3d660a7

Please sign in to comment.