Skip to content

Commit

Permalink
Check that error is thrown for invalid serialisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyh committed Jun 2, 2015
1 parent 684f32b commit 9fbb957
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/test_serialise.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

from pathlib import Path
from hypothesis import given, strategy

from hypothesis.specifiers import dictionary, strings

from tests import write_files, TestCase, slow
from eodatasets import serialise, compat, type as ptype


strings_without_trailing_underscore = strategy(
strings([chr(i) for i in range(128)])
) \
Expand Down Expand Up @@ -152,4 +150,12 @@ def __init__(self, a, b, c, d=None):
relative_to=Path('/tmp'),
key_separator=':'
)
)
)

def test_fails_on_unknown(self):
class UnknownClass(object):
pass

with self.assertRaises(ValueError) as context:
# It returns a generator, so we have to wrap it in a list to force evaluation.
list(serialise.as_flat_key_value({'a': 1, 'b': UnknownClass()}))

0 comments on commit 9fbb957

Please sign in to comment.