Browse Source

Introduce flags() method for overriding conf opts

Introducing the flags method in the networking_dpm base test case.
It provides an easy way of overriding config options during unit
tests.

Change-Id: I1abd257ed888e3278fe0b431770ea1854d1e7305
tags/2.0.0.0b1
Andreas Scheuring 2 years ago
parent
commit
c2982df181
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      networking_dpm/tests/base.py

+ 7
- 0
networking_dpm/tests/base.py View File

@@ -15,9 +15,16 @@
15 15
 # License for the specific language governing permissions and limitations
16 16
 # under the License.
17 17
 
18
+from oslo_config import cfg
19
+
18 20
 from neutron.tests import base
19 21
 
20 22
 
21 23
 class BaseTestCase(base.BaseTestCase):
22 24
 
23 25
     """Test case base class for all unit tests."""
26
+    def flags(self, **kw):
27
+        """Override config variables for a test."""
28
+        group = kw.pop('group', None)
29
+        for k, v in kw.items():
30
+            cfg.CONF.set_override(k, v, group, enforce_type=True)

Loading…
Cancel
Save