jinja icon indicating copy to clipboard operation
jinja copied to clipboard

Missing test coverage from pull request #1511?

Open jayaddison opened this issue 2 years ago • 5 comments

As part of pull request #1511, the changes may have fixed a bug related to native type rendering for iterator; it could be worth adding test coverage related to that.

Before #1511, the code was calling itertools.islice(values, 2) to retrieve the head elements from a values collection (potentially of an iterator type) and then using itertools.chain(head, values) to subsequently produce output.

In the case where values is an iterator, I think that works correctly. But in cases where values is not an iterator, it can result in output duplication (something that I think #1511 indirectly resolves with this check).

For example:

>>> from itertools import islice
>>> values = [1,2,3,4]
>>> head = islice(values, 2)
>>> from itertools import chain
>>> list(chain(head, values))
[1, 2, 1, 2, 3, 4]

jayaddison avatar Feb 18 '23 18:02 jayaddison

(note: opened this as a separate issue thread since the existing thread(s) have been locked)

jayaddison avatar Feb 18 '23 18:02 jayaddison

Happy to consider a PR that fixes this or adds tests.

davidism avatar Feb 18 '23 18:02 davidism

Work-in-progress at https://github.com/openculinary/jinja/tree/issue-1806/pr-1511-additional-test-coverage:

  • [x] Test coverage to demonstrate that a problem could have occurred during async rendering of templates containing native types
  • [ ] ~~Enable async support for pytest and tox~~ (doesn't appear to be required; continuous integration already includes async unit test coverage)

jayaddison avatar Feb 18 '23 23:02 jayaddison

Does the test coverage offered in #1807 seem reasonable for this? (that's one of my pull requests, and I'm trying to close/refresh a few that have been open for a while)

jayaddison avatar Sep 23 '23 17:09 jayaddison

Seems fine, just haven't had time to get to merges here.

davidism avatar Sep 23 '23 21:09 davidism