Skip to content

Commit

Permalink
Clarify test docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrlpld committed Jan 2, 2024
1 parent ab408d5 commit c55aeb3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions laces/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def set_example_template_content(self, content: str):

def test_render_html_with_template_name_set(self):
"""
Test the `render_html` with a set `template_name` attribute.
Test `render_html` method with a set `template_name` attribute.
"""

# -----------------------------------------------------------------------------
Expand All @@ -108,7 +108,8 @@ class ExampleComponent(Component):

def test_render_html_with_template_name_set_and_data_from_get_context_data(self):
"""
Test the `render_html` with `get_context_data` providing data for the context.
Test `render_html` method with `get_context_data` providing data for the
context.
"""

# -----------------------------------------------------------------------------
Expand All @@ -128,14 +129,15 @@ def get_context_data(self, parent_context):

def test_render_html_when_get_context_data_returns_None(self):
"""
Test the `render_html` method when `get_context_data` returns `None`.
This behavior was present when the class was extracted. It is not totally clear
why this specific check is needed. By default, the `get_context_data` method
provides and empty dict. If an override wanted to `get_context_data` return
`None`, it should be expected that no context data is available during
rendering. The underlying `template.render` method does not seem to care about
`None` as the context.
Test `render_html` method when `get_context_data` returns `None`.
The `render_html` method raises a `TypeError` when `None` is returned from
`get_context_method`. This behavior was present when the class was extracted
from Wagtail. It is not totally clear why this specific check is needed. By
default, the `get_context_data` method provides and empty dict. If an override
wanted to `get_context_data` return `None`, it should be expected that no
context data is available during rendering. The underlying `template.render`
method does not seem to be ok with `None` the provided context.
"""

# -----------------------------------------------------------------------------
Expand Down

0 comments on commit c55aeb3

Please sign in to comment.