10000 feat(py/dotpromptz): test harness that creates suites and test case methods dynamically by yesudeep · Pull Request #279 · google/dotprompt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(py/dotpromptz): test harness that creates suites and test case methods dynamically #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025

Conversation

yesudeep
Copy link
Collaborator

The previous implementation of the test harness simply iterated
over each suite and test case within it to run it. It made it hard
to identify and scope failures.

This technique generates test suites and test case methods dynamically
adding them to the module environment before the unittest.main
entry-point takes over.

CHANGELOG:

  • Update spec_test.py with the newer implementation.

USAGE:

zsh❯ uv run spec_test.py
...2025-05-14 02:29:57 [info     ] [TEST] history > basic_history > inserts conversation history with proper metadata and roles
.2025-05-14 02:29:57 [info     ] [TEST] history > empty_history > handles empty history by only rendering the template content
.2025-05-14 02:29:57 [info     ] [TEST] ifEquals > basic > renders false branch when values are not equal
.2025-05-14 02:29:57 [info     ] [TEST] ifEquals > basic > renders true branch when values are equal
.2025-05-14 02:29:57 [info     ] [TEST] ifEquals > type_safety > treats different types as not equal
.2025-05-14 02:29:57 [info     ] [TEST] json > basic > renders json in place
.2025-05-14 02:29:57 [info     ] [TEST] json > indented > renders json in place
.2025-05-14 02:29:57 [info     ] [TEST] media > basic > renders media part
.2025-05-14 02:29:57 [info     ] [TEST] metadata > ext > extension fields are parsed and added to 'ext'
.2025-05-14 02:29:57 [info     ] [TEST] metadata > metadata_state > accesses state object from metadata
.2025-05-14 02:29:58 [info     ] [TEST] metadata > metadata_state > handles missing state values
.2025-05-14 02:29:58 [info     ] [TEST] metadata > metadata_state > handles nested state objects
.2025-05-14 02:29:58 [info     ] [TEST] metadata > raw > raw frontmatter is provided on top of parsed frontmatter
.2025-05-14 02:29:58 [info     ] [TEST] partials > basic_partial > renders a basic partial
2025-05-14 02:29:58 [debug    ] {'event': 'partial_registered', 'name': 'greeting'}
.2025-05-14 02:29:58 [info     ] [TEST] partials > nested_resolved_partial > renders a resolver partial inside a resolver partial.
.2025-05-14 02:29:58 [info     ] [TEST] partials > partial_with_context > renders a partial with context
2025-05-14 02:29:58 [debug    ] {'event': 'partial_registered', 'name': 'userGreeting'}
.2025-05-14 02:29:58 [info     ] [TEST] partials > resolved_partial > renders a partial provided by a resolver.
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > any_field > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > array_of_scalars > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > enum_field > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > inferred_json_schema_from_properties > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > input_and_output > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > line_endings_crlf > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > named_schema_override_description > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > nested_named_schema > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > nested_object_in_array_and_out > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > required_field > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_json_schema_type > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_object > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description_extra_whitespace > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description_no_whitespace > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description_with_commas > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_no_description > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > wildcard_fields_with_other_fields > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > wildcard_fields_without_other_fields > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] role > all_roles > allows system, user, and model roles
.2025-05-14 02:29:58 [info     ] [TEST] role > system_only_prompt > inserts history after system prompt
.2025-05-14 02:29:58 [info     ] [TEST] role > syste
8000
m_role > renders variables in system and user role
.2025-05-14 02:29:58 [info     ] [TEST] section > basic_section > renders sequential sections with proper metadata and content boundaries
.2025-05-14 02:29:58 [info     ] [TEST] section > nested_sections > handles nested and reopened sections with proper metadata boundaries
.2025-05-14 02:29:58 [info     ] [TEST] unlessEquals > basic > renders false branch when values are equal
.2025-05-14 02:29:58 [info     ] [TEST] unlessEquals > basic > renders true branch when values are different
.2025-05-14 02:29:58 [info     ] [TEST] unlessEquals > type_safety > treats different types as not equal
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > does not escape HTML
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > overrides a default variable with a provided variable
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > uses a default variable
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > uses a provided variable
.
----------------------------------------------------------------------
Ran 51 tests in 0.054s

@yesudeep yesudeep changed the title feat: test harness that creates suites and test case methods dynamically feat(py/dotpromptz): test harness that creates suites and test case methods dynamically May 14, 2025
@yesudeep yesudeep force-pushed the yesudeep/feat/thirsty-ring branch from 67fe8cc to c7fbf8e Compare May 14, 2025 09:41
…ethods dynamically

The previous implementation of the test harness simply iterated
over each suite and test case within it to run it. It made it hard
to identify and scope failures.

This technique generates test suites and test case methods dynamically
adding them to the module environment before the `unittest.main`
entry-point takes over.

CHANGELOG:
- [ ] Update `spec_test.py` with the newer implementation.

USAGE:

```
zsh❯ uv run spec_test.py
...2025-05-14 02:29:57 [info     ] [TEST] history > basic_history > inserts conversation history with proper metadata and roles
.2025-05-14 02:29:57 [info     ] [TEST] history > empty_history > handles empty history by only rendering the template content
.2025-05-14 02:29:57 [info     ] [TEST] ifEquals > basic > renders false branch when values are not equal
.2025-05-14 02:29:57 [info     ] [TEST] ifEquals > basic > renders true branch when values are equal
.2025-05-14 02:29:57 [info     ] [TEST] ifEquals > type_safety > treats different types as not equal
.2025-05-14 02:29:57 [info     ] [TEST] json > basic > renders json in place
.2025-05-14 02:29:57 [info     ] [TEST] json > indented > renders json in place
.2025-05-14 02:29:57 [info     ] [TEST] media > basic > renders media part
.2025-05-14 02:29:57 [info     ] [TEST] metadata > ext > extension fields are parsed and added to 'ext'
.2025-05-14 02:29:57 [info     ] [TEST] metadata > metadata_state > accesses state object from metadata
.2025-05-14 02:29:58 [info     ] [TEST] metadata > metadata_state > handles missing state values
.2025-05-14 02:29:58 [info     ] [TEST] metadata > metadata_state > handles nested state objects
.2025-05-14 02:29:58 [info     ] [TEST] metadata > raw > raw frontmatter is provided on top of parsed frontmatter
.2025-05-14 02:29:58 [info     ] [TEST] partials > basic_partial > renders a basic partial
2025-05-14 02:29:58 [debug    ] {'event': 'partial_registered', 'name': 'greeting'}
.2025-05-14 02:29:58 [info     ] [TEST] partials > nested_resolved_partial > renders a resolver partial inside a resolver partial.
.2025-05-14 02:29:58 [info     ] [TEST] partials > partial_with_context > renders a partial with context
2025-05-14 02:29:58 [debug    ] {'event': 'partial_registered', 'name': 'userGreeting'}
.2025-05-14 02:29:58 [info     ] [TEST] partials > resolved_partial > renders a partial provided by a resolver.
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > any_field > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > array_of_scalars > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > enum_field > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > inferred_json_schema_from_properties > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > input_and_output > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > line_endings_crlf > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > named_schema_override_description > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > nested_named_schema > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > nested_object_in_array_and_out > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > required_field > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_json_schema_type > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_object > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description_extra_whitespace > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description_no_whitespace > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_description_with_commas > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > simple_scalar_no_description > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > wildcard_fields_with_other_fields > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] picoschema > wildcard_fields_without_other_fields > returns as expected
.2025-05-14 02:29:58 [info     ] [TEST] role > all_roles > allows system, user, and model roles
.2025-05-14 02:29:58 [info     ] [TEST] role > system_only_prompt > inserts history after system prompt
.2025-05-14 02:29:58 [info     ] [TEST] role > system_role > renders variables in system and user role
.2025-05-14 02:29:58 [info     ] [TEST] section > basic_section > renders sequential sections with proper metadata and content boundaries
.2025-05-14 02:29:58 [info     ] [TEST] section > nested_sections > handles nested and reopened sections with proper metadata boundaries
.2025-05-14 02:29:58 [info     ] [TEST] unlessEquals > basic > renders false branch when values are equal
.2025-05-14 02:29:58 [info     ] [TEST] unlessEquals > basic > renders true branch when values are different
.2025-05-14 02:29:58 [info     ] [TEST] unlessEquals > type_safety > treats different types as not equal
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > does not escape HTML
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > overrides a default variable with a provided variable
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > uses a default variable
.2025-05-14 02:29:58 [info     ] [TEST] variables > basic > uses a provided variable
.
----------------------------------------------------------------------
Ran 51 tests in 0.054s
```
@yesudeep yesudeep force-pushed the yesudeep/feat/thirsty-ring branch from c7fbf8e to 0f1fcc3 Compare May 14, 2025 09:42
@github-actions github-actions bot added documentation Improvements or additions to documentation root labels May 14, 2025
@yesudeep yesudeep merged commit 1dc2bda into main May 14, 2025
9 checks passed
@yesudeep yesudeep deleted the yesudeep/feat/thirsty-ring branch May 14, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation dotpromptz feature python root
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0