summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-04-14 10:18:41 -0400
committerGitHub <noreply@github.com>2020-04-14 10:18:41 -0400
commit48b15bf3fbfb74e1112c86c63f55dea2c76adfa3 (patch)
tree8d7a9c4fcccf46dd790f42dc359a58ffe3df8ce9
parente1a060487eeafc9c5944557f83c5a05e03b6852f (diff)
downloadvyos-cloud-init-48b15bf3fbfb74e1112c86c63f55dea2c76adfa3.tar.gz
vyos-cloud-init-48b15bf3fbfb74e1112c86c63f55dea2c76adfa3.zip
HACKING.rst: add pytest version gotchas section (#311)
And document that we can't yield in pytest.fixture functions due to the age of xenial's pytest.
-rw-r--r--HACKING.rst11
1 files changed, 10 insertions, 1 deletions
diff --git a/HACKING.rst b/HACKING.rst
index 59d6dd6c..7b371567 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -179,7 +179,6 @@ The following guidelines should be following:
subclass (indirectly) from ``TestCase`` (e.g.
`TestPrependBaseCommands`_)
-
* pytest tests should use bare ``assert`` statements, to take advantage
of pytest's `assertion introspection`_
@@ -187,11 +186,21 @@ The following guidelines should be following:
should be placed before the value under test:
``assert expected_value == function_under_test()``
+* As we still support Ubuntu 16.04 (Xenial Xerus), we can only use
+ pytest features that are available in v2.8.7. This is an
+ inexhaustive list of ways in which this may catch you out:
+
+ * Support for using ``yield`` in ``pytest.fixture`` functions was
+ only introduced in `pytest 3.0`_. Such functions must instead use
+ the ``pytest.yield_fixture`` decorator.
+
+
.. _pytest: https://docs.pytest.org/
.. _pytest fixtures: https://docs.pytest.org/en/latest/fixture.html
.. _TestGetPackageMirrorInfo: https://github.com/canonical/cloud-init/blob/42f69f410ab8850c02b1f53dd67c132aa8ef64f5/cloudinit/distros/tests/test_init.py\#L15
.. _TestPrependBaseCommands: https://github.com/canonical/cloud-init/blob/master/cloudinit/tests/test_subp.py#L9
.. _assertion introspection: https://docs.pytest.org/en/latest/assert.html
+.. _pytest 3.0: https://docs.pytest.org/en/latest/changelog.html#id1093
Type Annotations
----------------