Skip to content

Commit

Permalink
Merge pull request #729 from teojgo/bugfix/flex_alloc_access
Browse files Browse the repository at this point in the history
[bugfix] Fix crash in flexible task allocation due to refactoring of `SystemPartition`
  • Loading branch information
vkarak committed Apr 4, 2019
2 parents 49a83f6 + 9954114 commit a4583cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
15 changes: 15 additions & 0 deletions reframe/utility/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,21 @@ def __len__(self, *args, **kwargs):
def __reversed__(self, *args, **kwargs):
return self.__container.__reversed__(*args, **kwargs)

def __add__(self, other):
if not isinstance(other, collections.abc.Sequence):
return NotImplemented

return SequenceView(self.__container + other)

def __iadd__(self, other):
return NotImplemented

def __eq__(self, other):
if not isinstance(other, collections.abc.Sequence):
return NotImplemented

return self.__container == other


class MappingView(collections.abc.Mapping):
"""A read-only view of a mapping."""
Expand Down
14 changes: 11 additions & 3 deletions unittests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,15 +771,23 @@ def test_sequence(self):
self.assertEqual(2, l.count(2))

# Assert immutability
m = l + [3, 4]
self.assertEqual([1, 2, 2, 3, 4], m)
self.assertIsInstance(m, util.SequenceView)

m = l
l += [3, 4]
self.assertIsNot(m, l)
self.assertEqual([1, 2, 2], m)
self.assertEqual([1, 2, 2, 3, 4], l)
self.assertIsInstance(l, util.SequenceView)

with self.assertRaises(TypeError):
l[1] = 3

with self.assertRaises(TypeError):
l[1:2] = [3]

with self.assertRaises(TypeError):
l += [3, 4]

with self.assertRaises(TypeError):
l *= 3

Expand Down

0 comments on commit a4583cf

Please sign in to comment.