Skip to content

Commit

Permalink
Add name.setter property for EclKW
Browse files Browse the repository at this point in the history
  • Loading branch information
Pål Grønås Drange authored and Pål Grønås Drange committed Oct 4, 2017
1 parent cfef647 commit 2c25b4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions python/python/ecl/ecl/ecl_kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,10 @@ def name(self):
n = self._get_header()
return str(n) if n else ''

@name.setter
def name(self, value):
self.set_name(value)

def get_name(self):
return self.name

Expand Down
12 changes: 10 additions & 2 deletions python/tests/ecl/test_ecl_kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def copy_offset():

class KWTest(ExtendedTestCase):

def test_name(self):
kw = EclKW('TEST', 3, EclDataType.ECL_INT)
self.assertEqual(kw.name, 'TEST')
self.assertIn('TEST', repr(kw))
kw.name = 'SCHMEST'
self.assertEqual(kw.name, 'SCHMEST')
self.assertIn('SCHMEST', repr(kw))

def test_min_max(self):
kw = EclKW("TEST", 3, EclDataType.ECL_INT)
kw[0] = 10
Expand Down Expand Up @@ -207,14 +215,14 @@ def test_sliced_set(self):
self.assertEqual(kw[4] , 66)
self.assertEqual(kw[5] , 99)


def test_long_name(self):
with self.assertRaises(ValueError):
EclKW("LONGLONGNAME" , 10 , EclDataType.ECL_INT)

kw = EclKW("REGIONS" , 10 , EclDataType.ECL_INT)
with self.assertRaises(ValueError):
kw.setName("LONGLONGNAME")
kw.name = "LONGLONGNAME"


def test_abs(self):
Expand Down

0 comments on commit 2c25b4f

Please sign in to comment.