Skip to content

Commit

Permalink
Merge pull request equinor#248 from ShikhaMishra9/liftrestriction
Browse files Browse the repository at this point in the history
changing exception to warning for diff repcode
  • Loading branch information
ShikhaMishra9 authored Apr 3, 2020
2 parents adddf63 + d25e873 commit 0067e17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
3 changes: 2 additions & 1 deletion lib/src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,8 @@ object_vector parse_objects( const object_template& tmpl,
const auto msg = "count ({}) isn't 0 and representation "
"code ({}) changed, but value is not explicitly set";
const auto code = static_cast< int >(attr.reprc);
throw std::runtime_error(fmt::format(msg, count, code));
user_warning(fmt::format(msg, count, code));
attr.value = mpark::monostate{};
}

patch_missing_value( attr.value, count, attr.reprc );
Expand Down
34 changes: 14 additions & 20 deletions python/tests/test_logical_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ def test_absent_attribute_in_template(tmpdir, merge_files_oneLR):
obj = f.object('VERY_MUCH_TESTY_SET', 'OBJECT', 1, 1)
assert obj.attic['DEFAULT_ATTRIBUTE']



@pytest.mark.future_test_attributes
def test_global_default_attribute(tmpdir, merge_files_oneLR):
path = os.path.join(str(tmpdir), 'global-default-attribute.dlis')
Expand Down Expand Up @@ -237,24 +235,6 @@ def test_repcode(tmpdir, merge_files_oneLR, filename_p, attr_n, attr_reprc, attr
#assert attr.reprc == attr_reprc
assert attr == [attr_v]


def test_repcode_different_no_value(tmpdir, merge_files_oneLR):
path = os.path.join(str(tmpdir), 'different-repcode-no-value.dlis')
content = [
'data/chap3/start.dlis.part',
'data/chap3/template/default.dlis.part',
'data/chap3/object/object.dlis.part',
'data/chap3/objattr/csingle-novalue.dlis.part'
]
merge_files_oneLR(path, content)

with dlisio.load(path) as (f, *_):
with pytest.raises(RuntimeError) as excinfo:
# Load all objects
f.load()
assert "value is not explicitly set" in str(excinfo.value)


def test_repcode_invalid_in_template_value(tmpdir, merge_files_oneLR):
path = os.path.join(str(tmpdir), 'invalid-repcode.dlis')
content = [
Expand Down Expand Up @@ -302,6 +282,20 @@ def test_repcode_invalid_in_objects(tmpdir, merge_files_oneLR):
f.load()
assert "unknown representation code" in str(excinfo.value)

@pytest.mark.future_warning_repcode_different_no_value
def test_repcode_different_no_value(tmpdir, merge_files_oneLR):
path = os.path.join(str(tmpdir), 'different-repcode-no-value.dlis')
content = [
'data/chap3/start.dlis.part',
'data/chap3/template/default.dlis.part',
'data/chap3/object/object.dlis.part',
'data/chap3/objattr/csingle-novalue.dlis.part'
]
merge_files_oneLR(path, content)

with dlisio.load(path) as (f, *_):
obj = f.object('VERY_MUCH_TESTY_SET', 'OBJECT', 1, 1)
assert obj.attic['DEFAULT_ATTRIBUTE'] == [0j, 0j]

@pytest.mark.future_test_attributes
def test_count0_novalue(tmpdir, merge_files_oneLR):
Expand Down

0 comments on commit 0067e17

Please sign in to comment.