summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2018-09-19 09:37:47 -0500
committerJason Madden <jamadden@gmail.com>2018-09-19 09:37:47 -0500
commit39d1732fff8401d779fdf91783404a15ab0135f3 (patch)
tree4d9a79703614b257d1549ea61cc229a4a766d72d /src
parentb5964f548c8ecb87b0c8c3b3b1463cd478a05237 (diff)
downloadzope-schema-39d1732fff8401d779fdf91783404a15ab0135f3.tar.gz
Fix passing ``None`` as the description to a field constructor.
Fixes #69.
Diffstat (limited to 'src')
-rw-r--r--src/zope/schema/_bootstrapfields.py4
-rw-r--r--src/zope/schema/tests/test__bootstrapfields.py25
2 files changed, 28 insertions, 1 deletions
diff --git a/src/zope/schema/_bootstrapfields.py b/src/zope/schema/_bootstrapfields.py
index 0cfa398..0ba053f 100644
--- a/src/zope/schema/_bootstrapfields.py
+++ b/src/zope/schema/_bootstrapfields.py
@@ -244,7 +244,9 @@ class Field(Attribute):
# Fix leading whitespace that occurs when using multi-line
# strings, but don't overwrite the original, we need to
# preserve it (it could be a MessageID).
- doc_description = '\n'.join(_DocStringHelpers.docstring_to_lines(description)[:-1])
+ doc_description = '\n'.join(
+ _DocStringHelpers.docstring_to_lines(description or u'')[:-1]
+ )
if title:
if doc_description:
diff --git a/src/zope/schema/tests/test__bootstrapfields.py b/src/zope/schema/tests/test__bootstrapfields.py
index 3932e85..c8bb2b0 100644
--- a/src/zope/schema/tests/test__bootstrapfields.py
+++ b/src/zope/schema/tests/test__bootstrapfields.py
@@ -486,6 +486,31 @@ class FieldTests(EqualityTestsMixin,
""")
)
+ def test_ctor_description_none(self):
+ # None values for description don't break the docs.
+ import textwrap
+
+ description = None
+
+ title = u'A title'
+
+ field = self._makeOne(title=title, description=description)
+
+ self.assertIs(field.title, title)
+ self.assertIs(field.description, description)
+
+ self.assertEqual(
+ field.getDoc(),
+ textwrap.dedent("""\
+ A title
+
+ :Implementation: :class:`zope.schema.Field`
+ :Read Only: False
+ :Required: True
+ :Default Value: None
+ """)
+ )
+
def test_ctor_defaults(self):
field = self._makeOne()