From 9fbb9571aae6bbc35b8c9ed5ab5531d435125b3a Mon Sep 17 00:00:00 2001 From: Jeremy Hooke Date: Tue, 2 Jun 2015 14:45:16 +1000 Subject: [PATCH] Check that error is thrown for invalid serialisation. --- tests/test_serialise.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_serialise.py b/tests/test_serialise.py index 7df4d3c3..e8d2b870 100644 --- a/tests/test_serialise.py +++ b/tests/test_serialise.py @@ -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)]) ) \ @@ -152,4 +150,12 @@ def __init__(self, a, b, c, d=None): relative_to=Path('/tmp'), key_separator=':' ) - ) \ No newline at end of file + ) + + 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()}))