summaryrefslogtreecommitdiff
path: root/cloudinit/tests/test_conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/tests/test_conftest.py')
-rw-r--r--cloudinit/tests/test_conftest.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/cloudinit/tests/test_conftest.py b/cloudinit/tests/test_conftest.py
index 62a5361d..11b91327 100644
--- a/cloudinit/tests/test_conftest.py
+++ b/cloudinit/tests/test_conftest.py
@@ -1,9 +1,11 @@
import pytest
from cloudinit import util
+from cloudinit.tests.helpers import CiTestCase
class TestDisableSubpUsage:
+ """Test that the disable_subp_usage fixture behaves as expected."""
def test_using_subp_raises_assertion_error(self):
with pytest.raises(AssertionError):
@@ -16,3 +18,23 @@ class TestDisableSubpUsage:
@pytest.mark.parametrize('disable_subp_usage', [False], indirect=True)
def test_subp_usage_can_be_reenabled(self):
util.subp(['whoami'])
+
+
+class TestDisableSubpUsageInTestSubclass(CiTestCase):
+ """Test that disable_subp_usage doesn't impact CiTestCase's subp logic."""
+
+ def test_using_subp_raises_exception(self):
+ with pytest.raises(Exception):
+ util.subp(["some", "args"])
+
+ def test_typeerrors_on_incorrect_usage(self):
+ with pytest.raises(TypeError):
+ util.subp()
+
+ def test_subp_usage_can_be_reenabled(self):
+ _old_allowed_subp = self.allow_subp
+ self.allowed_subp = True
+ try:
+ util.subp(['bash', '-c', 'true'])
+ finally:
+ self.allowed_subp = _old_allowed_subp