summaryrefslogtreecommitdiff
path: root/cloudinit/tests
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-04-23 15:34:07 -0400
committerGitHub <noreply@github.com>2020-04-23 15:34:07 -0400
commit845a393d8bb641216b1d311b09486b0aa19f1e9c (patch)
treed5811f87013b893e021c112a908068e36fa69d82 /cloudinit/tests
parent1b049e6e51a9ac1ca02bf33629ede5c47c5b1941 (diff)
downloadvyos-cloud-init-845a393d8bb641216b1d311b09486b0aa19f1e9c.tar.gz
vyos-cloud-init-845a393d8bb641216b1d311b09486b0aa19f1e9c.zip
conftest: introduce disable_subp_usage autouse fixture (#304)
This mirrors the behaviour of CiTestCase.allowed_subp, by causing all calls to util.subp to raise an AssertionError.
Diffstat (limited to 'cloudinit/tests')
-rw-r--r--cloudinit/tests/test_conftest.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/cloudinit/tests/test_conftest.py b/cloudinit/tests/test_conftest.py
new file mode 100644
index 00000000..62a5361d
--- /dev/null
+++ b/cloudinit/tests/test_conftest.py
@@ -0,0 +1,18 @@
+import pytest
+
+from cloudinit import util
+
+
+class TestDisableSubpUsage:
+
+ def test_using_subp_raises_assertion_error(self):
+ with pytest.raises(AssertionError):
+ util.subp(["some", "args"])
+
+ def test_typeerrors_on_incorrect_usage(self):
+ with pytest.raises(TypeError):
+ util.subp()
+
+ @pytest.mark.parametrize('disable_subp_usage', [False], indirect=True)
+ def test_subp_usage_can_be_reenabled(self):
+ util.subp(['whoami'])