diff --git a/CHANGES.md b/CHANGES.md index 0d650fd..9fe1747 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Revision History +## 0.6.1 (2015/02/23) + +- Fixed handling of `None` in `NullableString`. + ## 0.6 (2015/02/23) - Added preliminary support for JSON serialization (@pr0xmeh). diff --git a/yorm/__init__.py b/yorm/__init__.py index 050d0a9..7b14660 100644 --- a/yorm/__init__.py +++ b/yorm/__init__.py @@ -3,7 +3,7 @@ import sys __project__ = 'YORM' -__version__ = '0.6' +__version__ = '0.6.1' VERSION = __project__ + '-' + __version__ diff --git a/yorm/test/__init__.py b/yorm/test/__init__.py index 2e47072..031a459 100644 --- a/yorm/test/__init__.py +++ b/yorm/test/__init__.py @@ -7,6 +7,10 @@ import expecter +def is_none(x): + return x is None + + def is_true(x): return x is True @@ -23,6 +27,7 @@ def missing(x): return not os.path.exists(x) +expecter.add_expectation(is_none) expecter.add_expectation(is_true) expecter.add_expectation(is_false) expecter.add_expectation(exists) diff --git a/yorm/test/test_types_extended.py b/yorm/test/test_types_extended.py index bba2699..d0d902c 100644 --- a/yorm/test/test_types_extended.py +++ b/yorm/test/test_types_extended.py @@ -1,10 +1,12 @@ -# pylint: disable=missing-docstring,no-self-use,misplaced-comparison-constant +# pylint: disable=missing-docstring,unused-variable,misplaced-comparison-constant,no-self-use import pytest +from expecter import expect from yorm.utilities import attr -from yorm.types import Integer, String, Float -from yorm.types.extended import Markdown, AttributeDictionary, SortedList +from yorm.types.standard import Integer, String, Float +from yorm.types.extended import (NullableString, Markdown, + AttributeDictionary, SortedList) # CLASSES ###################################################################### @@ -37,6 +39,20 @@ class UnknownSortedList(SortedList): # TESTS ######################################################################## +def describe_nullable_string(): + + def describe_to_value(): + + def it_allows_none(): + expect(NullableString.to_value(None)).is_none() + + def describe_to_data(): + + def it_allows_none(): + expect(NullableString.to_data(None)).is_none() + + +# TODO: make these tests look like `test_types_standard.py` class TestMarkdown: """Unit tests for the `Markdown` converter.""" diff --git a/yorm/types/standard.py b/yorm/types/standard.py index e7768e3..abd4efa 100644 --- a/yorm/types/standard.py +++ b/yorm/types/standard.py @@ -53,7 +53,7 @@ def _optimize_for_quoting(value): for num in (int, float): try: return num(value) - except ValueError: + except (TypeError, ValueError): continue return value