Skip to content

Commit

Permalink
Fix tests:
Browse files Browse the repository at this point in the history
* Fix tests to run with `lxml >= 5.3`, thus requiring at least that version.
* Drop support for deprecated `persistent.dict.PersistentDict`.
* Add support for Sphinx 8.
  • Loading branch information
icemac committed Aug 12, 2024
1 parent d6032e3 commit 53fcbed
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 52 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Changelog

- Add basque (eu) translation.

- Fix tests to run with ``lxml >= 5.3``, thus requiring at least that version.

- Drop support for deprecated ``persistent.dict.PersistentDict``, as a
replacement please use ``persistent.mapping.PersistentMapping`` instead.


5.1 (2023-07-19)
----------------
Expand Down
38 changes: 16 additions & 22 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys
import os
import pkg_resources

sys.path.append(os.path.abspath('../src'))
rqmt = pkg_resources.require('z3c.form')[0]

Expand Down Expand Up @@ -44,7 +45,7 @@
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = {'.rst': 'restructuredtext'}

# The encoding of source files.
#source_encoding = 'utf-8-sig'
Expand Down Expand Up @@ -103,7 +104,6 @@
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down Expand Up @@ -188,26 +188,25 @@
# Output file base name for HTML help builder.
htmlhelp_basename = 'z3cformdoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'z3cform.tex', 'z3c.form Documentation',
'Zope Foundation and Contributors', 'manual'),
('index', 'z3cform.tex', 'z3c.form Documentation',
'Zope Foundation and Contributors', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand All @@ -230,29 +229,25 @@
# If false, no module index is generated.
#latex_domain_indices = True


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'z3cform', 'z3c.form Documentation',
['Zope Foundation and Contributors'], 1)
]
man_pages = [('index', 'z3cform', 'z3c.form Documentation',
['Zope Foundation and Contributors'], 1)]

# If true, show URL addresses after external links.
#man_show_urls = False


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'z3cform', 'z3c.form Documentation',
'Zope Foundation and Contributors', 'z3cform', 'One line description of project.',
'Miscellaneous'),
('index', 'z3cform', 'z3c.form Documentation',
'Zope Foundation and Contributors', 'z3cform',
'An advanced form and widget framework for Zope 3.', 'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
Expand All @@ -267,10 +262,9 @@
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'https://docs.python.org/': None,
'python': ('https://docs.python.org/', None),
}

autodoc_default_flags = ['members', 'show-inheritance']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def read(*rnames):
'zope.pagetemplate >= 3.6.2',
],
test=[
'lxml >= 4.7.1',
'lxml >= 5.3',
'persistent',
'z3c.template >= 1.3',
'zc.sourcefactory',
Expand Down
5 changes: 1 addition & 4 deletions src/z3c/form/datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@

ALLOWED_DATA_CLASSES = [dict]
try:
import persistent.dict
import persistent.mapping
ALLOWED_DATA_CLASSES.append(persistent.mapping.PersistentMapping)
ALLOWED_DATA_CLASSES.append(persistent.dict.PersistentDict)
except ImportError:
pass

Expand Down Expand Up @@ -120,8 +118,7 @@ class DictionaryField(DataManager):
"""

zope.component.adapts(
dict, zope.schema.interfaces.IField)
zope.component.adapts(dict, zope.schema.interfaces.IField)

_allowed_data_classes = tuple(ALLOWED_DATA_CLASSES)

Expand Down
5 changes: 1 addition & 4 deletions src/z3c/form/datamanager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ The datamanager can really only deal with dictionaries and mapping types:

>>> import zope.interface.common.mapping
>>> import persistent.mapping
>>> import persistent.dict

>>> @zope.interface.implementer(zope.interface.common.mapping.IMapping)
... class MyMapping(object):
... pass
Expand All @@ -271,9 +271,6 @@ The datamanager can really only deal with dictionaries and mapping types:
>>> datamanager.DictionaryField(persistent.mapping.PersistentMapping(),
... IPerson['name'])
<z3c.form.datamanager.DictionaryField object at ...>
>>> datamanager.DictionaryField(persistent.dict.PersistentDict(),
... IPerson['name'])
<z3c.form.datamanager.DictionaryField object at ...>

>>> datamanager.DictionaryField([], IPerson['name'])
Traceback (most recent call last):
Expand Down
12 changes: 6 additions & 6 deletions src/z3c/form/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ When the form renders, the label has now changed:
>>> addForm = PersonAddForm(root, TestRequest())
>>> addTemplate(addForm)
>>> addForm.update()
>>> print(testing.render(addForm, './/xmlns:div[2][@class="row"]')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(addForm, './/xmlns:div[2][@class="row"]'))
<div class="row">
<label for="form-widgets-name">Full Name</label>
<input id="form-widgets-name" name="form.widgets.name" class="text-widget required textline-field" value="" type="text" />
Expand Down Expand Up @@ -966,7 +966,7 @@ After registering the new action manager,
the add form should display a cancel button:

>>> addForm.update()
>>> print(testing.render(addForm, './/xmlns:div[@class="action"]')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(addForm, './/xmlns:div[@class="action"]'))
<div class="action">
<input id="form-buttons-add" name="form.buttons.add" class="submit-widget button-field" value="Add" type="submit" />
</div>
Expand Down Expand Up @@ -1158,7 +1158,7 @@ Let's now resubmit the form with valid data, so the data should be updated.
>>> editForm = PersonEditForm(root['srichter'], request)
>>> addTemplate(editForm)
>>> editForm.update()
>>> print(testing.render(editForm, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(editForm, './/xmlns:i'))
<i >Data successfully updated.</i>
...

Expand Down Expand Up @@ -1222,7 +1222,7 @@ When submitting the form without any changes, the form will tell you so.
>>> editForm = PersonEditForm(root['srichter'], request)
>>> addTemplate(editForm)
>>> editForm.update()
>>> print(testing.render(editForm, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(editForm, './/xmlns:i'))
<i >No changes were applied.</i>
...

Expand All @@ -1248,7 +1248,7 @@ Let's now change the ``noChangesMessage``:

>>> editForm.noChangesMessage = 'No changes were detected in the form data.'
>>> editForm.update()
>>> print(testing.render(editForm, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(editForm, './/xmlns:i'))
<i >No changes were detected in the form data.</i>
...

Expand Down Expand Up @@ -1787,7 +1787,7 @@ The button will be available when context is not empty.
>>> myForm = SequenceForm(context, request)
>>> myForm.update()
>>> addTemplate(myForm)
>>> print(testing.render(myForm, './/xmlns:div[@class="action"]')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(myForm, './/xmlns:div[@class="action"]'))
<div class="action">
<input id="form-buttons-empty" name="form.buttons.empty" class="submit-widget button-field" value="Empty" type="submit" />
</div>
Expand Down
30 changes: 15 additions & 15 deletions src/z3c/form/group.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ Let's now submit the form, but forgetting to enter the address:

>>> add = RegistrationAddForm(None, request)
>>> add.update()
>>> print(testing.render(add, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(add, './/xmlns:i'))
<i >There were some errors.</i>
...

>>> print(testing.render(add, './/xmlns:fieldset[1]/xmlns:ul')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(add, './/xmlns:fieldset[1]/xmlns:ul'))
<ul >
<li>
Address: <div class="error">Required input is missing.</div>
Expand Down Expand Up @@ -235,11 +235,11 @@ So what happens, if errors happen inside and outside a group?

>>> add = RegistrationAddForm(None, request)
>>> add.update()
>>> print(testing.render(add, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(add, './/xmlns:i'))
<i >There were some errors.</i>
...

>>> print(testing.render(add, './/xmlns:ul')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(add, './/xmlns:ul'))
<ul >
<li>
Last Name:
Expand All @@ -255,7 +255,7 @@ So what happens, if errors happen inside and outside a group?
</ul>
...

>>> print(testing.render(add, './/xmlns:fieldset[1]/xmlns:ul')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(add, './/xmlns:fieldset[1]/xmlns:ul'))
<ul >
<li>
Address: <div class="error">Required input is missing.</div>
Expand Down Expand Up @@ -399,11 +399,11 @@ The behavior when an error occurs is identical to that of the add form:

>>> edit = RegistrationEditForm(reg, request)
>>> edit.update()
>>> print(testing.render(edit, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:i'))
<i >There were some errors.</i>
...

>>> print(testing.render(edit, './/xmlns:ul')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:ul'))
<ul >
<li>
Address:
Expand All @@ -412,7 +412,7 @@ The behavior when an error occurs is identical to that of the add form:
</ul>
...

>>> print(testing.render(edit, './/xmlns:fieldset/xmlns:ul')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:fieldset/xmlns:ul'))
<ul >
<li>
Address: <div class="error">Required input is missing.</div>
Expand Down Expand Up @@ -450,7 +450,7 @@ Let's now complete the form successfully:

The success message will be shown on the form, ...

>>> print(testing.render(edit, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:i'))
<i >Data successfully updated.</i>
...

Expand Down Expand Up @@ -737,7 +737,7 @@ Richter gave his BMW to Paul Carduner because he is such a nice guy.

We'll see if everything worked on the form side.

>>> print(testing.render(edit, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:i'))
<i >Data successfully updated.</i>
...

Expand Down Expand Up @@ -817,7 +817,7 @@ Richter gave his BMW to Paul Carduner because he is such a nice guy.

We'll see if everything worked on the form side.

>>> print(testing.render(edit, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:i'))
<i >Data successfully updated.</i>
...

Expand Down Expand Up @@ -857,11 +857,11 @@ invalid object for the test missing input errors:
>>> edit = RegistrationEditForm(reg, request)
>>> edit.update()
>>> data, errors = edit.extractData()
>>> print(testing.render(edit, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:i'))
<i >There were some errors.</i>
...

>>> print(testing.render(edit, './/xmlns:fieldset/xmlns:ul')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:fieldset/xmlns:ul'))
<ul >
<li>
License:
Expand Down Expand Up @@ -1016,11 +1016,11 @@ Now test the error handling if just one missing value is given in a group:

>>> edit.update()
>>> data, errors = edit.extractData()
>>> print(testing.render(edit, './/xmlns:i')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:i'))
<i >There were some errors.</i>
...

>>> print(testing.render(edit, './/xmlns:fieldset/xmlns:ul')) # doctest: +NOPARSE_MARKUP
>>> print(testing.render(edit, './/xmlns:fieldset/xmlns:ul'))
<ul >
<li>
Last Name:
Expand Down

0 comments on commit 53fcbed

Please sign in to comment.