From 9b0199a5478208a5880ad8926cb4838637a6db42 Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Thu, 26 Oct 2017 12:59:42 +0100 Subject: [PATCH] Ensure that venv is used This is to ensure that the charm doesn't trample on the system packages for the things that it needs to install, and that it will cooperate with another reactive charm, especially as it is a subordinate. Also fix some PEP8 E722 errors as that seems to have been added to the pep8 standard set. Change-Id: I9efb78c6f738db2284677dbde85f9e2a3ed0a6fe --- .gitignore | 1 + src/layer.yaml | 5 ++++- unit_tests/test_lib_barbican_softhsm.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a68c28d..98c9c5a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ interfaces trusty .testrepository __pycache__ +.stestr diff --git a/src/layer.yaml b/src/layer.yaml index ed5e90e..cb07dcb 100644 --- a/src/layer.yaml +++ b/src/layer.yaml @@ -1,3 +1,6 @@ includes: ['layer:openstack', 'interface:barbican-hsm'] repo: https://github.com/openstack/charm-barbican-softhsm - +options: + basic: + use_venv: true + include_system_packages: true diff --git a/unit_tests/test_lib_barbican_softhsm.py b/unit_tests/test_lib_barbican_softhsm.py index 404b3ba..f4f4d43 100644 --- a/unit_tests/test_lib_barbican_softhsm.py +++ b/unit_tests/test_lib_barbican_softhsm.py @@ -47,8 +47,8 @@ class TestSoftHSM(test_utils.PatchHelper): # test with no file (patch open so that it raises an error) mock_open = mock.MagicMock(return_value=mock.sentinel.file_handle) with mock.patch('builtins.open', mock_open): - def raise_exception(): - raise Exception("Supposed to break") + def raise_exception(*args): + raise OSError("Supposed to break") mock_open.side_effect = raise_exception pin, so_pin = softhsm.read_pins_from_store() self.assertEqual(pin, None)