Skip to content

Instantly share code, notes, and snippets.

---
- hosts: all
gather_facts: false
vars:
secret_value: "Something secret"
tasks:
- name: task with stdout
command: 'echo {{ secret_value }}'
@jlaska
jlaska / gist:eda67b6a02726fccf723
Created December 9, 2015 21:38
setuptools registered pytest plugins
# TOXENV=py27-ansible_stable tox -- -x -s --trace-config
...
=========================================================================================================================================================================== test session starts ============================================================================================================================================================================
platform darwin -- Python 2.7.10, pytest-2.8.4, py-1.4.31, pluggy-0.3.1
using: pytest-2.8.4 pylib-1.4.31
setuptools registered plugins:
pytest-ansible-1.2.5 at /Users/jlaska/Projects/pytest-ansible.git/pytest_ansible/plugin.pyc
pytest-cov-2.2.0 at /Users/jlaska/Projects/pytest-ansible.git/.tox/py27-ansible_stable/lib/python2.7/site-packages/pytest_cov/plugin.pyc
active plugins:
...
@jlaska
jlaska / gist:ee74af42199ba4d8dacb
Created March 19, 2015 13:16
rax.py traceback
Traceback (most recent call last):
File "rax.py", line 420, in <module>
main()
File "rax.py", line 413, in main
_list(regions)
File "rax.py", line 280, in _list
metadata = vol.volume_image_metadata
File "/Users/jlaska/Downloads/VirtualEnvs/ansible/lib/python2.7/site-packages/pyrax/resource.py", line 92, in __getattr__
"'%s'." % (self.__class__, key))
AttributeError: '<class 'pyrax.cloudblockstorage.CloudBlockStorageVolume'>' object has no attribute 'volume_image_metadata'.
@jlaska
jlaska / rax.py --list
Created November 17, 2014 20:06
TypeError: string indices must be integers
Traceback (most recent call last):
File "./plugins/inventory/rax.py", line 284, in <module>
main()
File "./plugins/inventory/rax.py", line 277, in main
_list(regions)
File "./plugins/inventory/rax.py", line 187, in _list
imagegroup = 'image-%s' % images[server.image['id']]
TypeError: string indices must be integers
@jlaska
jlaska / test.py
Last active August 29, 2015 14:07
How to define a pytest fixture that returns other fixtures at runtime?
import pytest
@pytest.fixture(scope="function")
def user_one(request):
return dict(username="one", first_name="One", last_name="User", email="one@example.com")
@pytest.fixture(scope="function")
def user_two(request):
PLAY [A play with unicode: ¢ £ ¤ ¥] *******************************************
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]
TASK: [A task name with unicode: è é ê ë] *************************************
ok: [127.0.0.1] => {
"msg": "hi there"
}
diff --git a/tox.ini b/tox.ini
index fe8e1be..7f3f57b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,9 +8,10 @@ envlist =
[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/lib/
+ NOSETESTS = 'nosetests'
diff --git a/tests/requirements.txt b/tests/requirements.txt
index 0a6a42c..fb8f594 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,5 +1,7 @@
coverage>=3.7.1
fauxquests>=1.1
+nose
+nosexml
@jlaska
jlaska / test_fixtures.py
Created July 9, 2014 14:43
Attempting to override existing pytest fixtures with pytest_generate_tests
import os
import pytest
import yaml
from inflect import engine
# General purpose fixtures, typically defined elsewhere and included in a top-level conftest
@pytest.fixture(scope="class")
def organization(request):
return "organization"
PLAY [add 10 hosts to inventory] **********************************************
GATHERING FACTS ***************************************************************
ok: [local]
TASK: [create inventory] ******************************************************
ok: [local] => (item=0)
ok: [local] => (item=1)
ok: [local] => (item=2)