summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-06-08 17:08:43 -0400
committerGitHub <noreply@github.com>2020-06-08 17:08:43 -0400
commit87b8080f3163574580a207f15ff308da6010b0ff (patch)
tree6e9aa0a6f86a95d085ace5297dc980893176cc4a
parent4e534a7c22514d162e65cc773d44b706fe877cea (diff)
downloadvyos-cloud-init-87b8080f3163574580a207f15ff308da6010b0ff.tar.gz
vyos-cloud-init-87b8080f3163574580a207f15ff308da6010b0ff.zip
test: move conftest.py to top-level, to cover tests/ also (#414)
* test_opennebula: convert TestParseShellConfig to a pytest test And allow it to run bash. (We aren't aiming to convert TestCase tests to pytest tests as a rule. In this case, I needed to change its implementation to limit subp usage, and I chose pytest over CiTestCase.) * test: move conftest.py to top-level, to cover tests/ also This gives us a single conftest.py which is shared by all tests in the project.
-rw-r--r--conftest.py (renamed from cloudinit/conftest.py)0
-rw-r--r--tests/unittests/test_datasource/test_opennebula.py8
-rw-r--r--tests/unittests/test_render_cloudcfg.py1
3 files changed, 7 insertions, 2 deletions
diff --git a/cloudinit/conftest.py b/conftest.py
index 251bca59..251bca59 100644
--- a/cloudinit/conftest.py
+++ b/conftest.py
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py
index de896a9e..7c859c8a 100644
--- a/tests/unittests/test_datasource/test_opennebula.py
+++ b/tests/unittests/test_datasource/test_opennebula.py
@@ -9,6 +9,8 @@ import os
import pwd
import unittest
+import pytest
+
TEST_VARS = {
'VAR1': 'single',
@@ -914,12 +916,14 @@ class TestOpenNebulaNetwork(unittest.TestCase):
self.assertEqual(expected, net.gen_conf())
-class TestParseShellConfig(unittest.TestCase):
+class TestParseShellConfig:
+
+ @pytest.mark.parametrize('disable_subp_usage', ['bash'], indirect=True)
def test_no_seconds(self):
cfg = '\n'.join(["foo=bar", "SECONDS=2", "xx=foo"])
# we could test 'sleep 2', but that would make the test run slower.
ret = ds.parse_shell_config(cfg)
- self.assertEqual(ret, {"foo": "bar", "xx": "foo"})
+ assert ret == {"foo": "bar", "xx": "foo"}
def populate_context_dir(path, variables):
diff --git a/tests/unittests/test_render_cloudcfg.py b/tests/unittests/test_render_cloudcfg.py
index 393a78b1..696915a3 100644
--- a/tests/unittests/test_render_cloudcfg.py
+++ b/tests/unittests/test_render_cloudcfg.py
@@ -13,6 +13,7 @@ DISTRO_VARIANTS = ["amazon", "arch", "centos", "debian", "fedora", "freebsd",
"netbsd", "openbsd", "rhel", "suse", "ubuntu", "unknown"]
+@pytest.mark.parametrize('disable_subp_usage', [sys.executable], indirect=True)
class TestRenderCloudCfg:
cmd = [sys.executable, os.path.realpath('tools/render-cloudcfg')]