-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
Add jinja2 groupby filter override to cast namedtuple to tuple. Fixes #20098 #20362
Changes from all commits
970cee9
8b39b1e
cd136dd
60f06cf
ef42e84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
posix/ci/group2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# We don't set -u here, due to pypa/virtualenv#150 | ||
set -ex | ||
|
||
MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') | ||
|
||
# This is needed for the ubuntu1604py3 tests | ||
# Ubuntu patches virtualenv to make the default python2 | ||
# but for the python3 tests we need virtualenv to use python3 | ||
if [ -f /usr/bin/python3 ] | ||
then | ||
PYTHON="--python /usr/bin/python3" | ||
else | ||
PYTHON="" | ||
fi | ||
|
||
virtualenv --system-site-packages $PYTHON "${MYTMPDIR}/jinja2" | ||
|
||
source "${MYTMPDIR}/jinja2/bin/activate" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll give it another shot. I had it there, but it remember it failing on the osx build, which selected a different python than the venv that is used in the tests. Just not setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, sorry I wasn't clear. I didn't mean to change how you're selecting the python version. I just meant that it would be good to run I actually need to improve There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that is more my mistake for reading your comments on my phone. I've restored my original logic, and applied what you were referencing. |
||
|
||
which python | ||
python -V | ||
|
||
pip install -U jinja2==2.9.4 | ||
|
||
ansible-playbook -i ../../inventory test_jinja2_groupby.yml -v "$@" | ||
|
||
pip install -U "jinja2<2.9.0" | ||
|
||
ansible-playbook -i ../../inventory test_jinja2_groupby.yml -v "$@" | ||
|
||
deactivate | ||
|
||
rm -r "${MYTMPDIR}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: Test jinja2 groupby | ||
hosts: localhost | ||
gather_facts: False | ||
connection: local | ||
vars: | ||
fruits: | ||
- name: apple | ||
enjoy: yes | ||
- name: orange | ||
enjoy: no | ||
- name: strawberry | ||
enjoy: yes | ||
expected: [[false, [{"enjoy": false, "name": "orange"}]], [true, [{"enjoy": true, "name": "apple"}, {"enjoy": true, "name": "strawberry"}]]] | ||
tasks: | ||
- debug: | ||
msg: "{{ lookup('pipe', 'pip freeze | grep -i jinja2') }}" | ||
|
||
- set_fact: | ||
result: "{{ fruits | groupby('enjoy') }}" | ||
|
||
- assert: | ||
that: | ||
- result == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide a comment explaining why this is needed?