]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests reset the cluster name after every unit test
authorAlfredo Deza <adeza@redhat.com>
Mon, 24 Sep 2018 14:29:12 +0000 (10:29 -0400)
committerAlfredo Deza <adeza@redhat.com>
Tue, 25 Sep 2018 22:04:30 +0000 (18:04 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 877ee1a27e0651355812e27fbc6ac0a87ea56a68)

src/ceph-volume/ceph_volume/tests/conftest.py

index 5222b45e76d674539b2199360562ece1db9341cb..dfa84e5677033f4f47a9aab0050515216773a60a 100644 (file)
@@ -85,6 +85,22 @@ def stub_call(monkeypatch):
     return apply
 
 
+@pytest.fixture(autouse=True)
+def reset_cluster_name(request, monkeypatch):
+    """
+    The globally available ``ceph_volume.conf.cluster`` might get mangled in
+    tests, make sure that after evert test, it gets reset, preventing pollution
+    going into other tests later.
+    """
+    def fin():
+        conf.cluster = None
+        try:
+            os.environ.pop('CEPH_CONF')
+        except KeyError:
+            pass
+    request.addfinalizer(fin)
+
+
 @pytest.fixture
 def conf_ceph(monkeypatch):
     """