From 8fedfb579fe2bca916922e9b33517ca3c7e1b824 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 31 Jan 2023 11:56:18 -0500 Subject: [PATCH] ragweed: switch to pytest framework due to deprecation of nose Signed-off-by: Yehuda Sadeh --- README.rst | 6 +++--- bootstrap | 2 +- pytest.ini | 3 +++ ragweed/framework.py | 10 +++++++++- requirements.txt | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 pytest.ini diff --git a/README.rst b/README.rst index 015d775..5cb6545 100644 --- a/README.rst +++ b/README.rst @@ -14,7 +14,7 @@ Each of these phases can be executed separately. For more information on the background of the tests visit: https://www.spinics.net/lists/ceph-devel/msg34636.html -The tests use the Nose test framework. To get started, ensure you have +The tests use the pytest test framework. To get started, ensure you have the ``virtualenv`` software installed; e.g. on Debian/Ubuntu:: sudo apt-get install python-virtualenv @@ -33,7 +33,7 @@ service and two different credentials. A sample configuration file named Once you have that file copied and edited, you can run the tests with:: - RAGWEED_CONF=ragweed.conf RAGWEED_STAGES=prepare,check ./virtualenv/bin/nosetests -v + RAGWEED_CONF=ragweed.conf RAGWEED_STAGES=prepare,check ./virtualenv/bin/pytest -v The phase(s) of the tests are set via ``RAGWEED_STAGES``. The options for ``RAGWEED_STAGES`` are ``prepare`` and ``check``. ``test`` can be used instead of ``check``. @@ -63,4 +63,4 @@ OR:: Finally run the ragweed tests:: - RAGWEED_CONF=ragweed.conf RAGWEED_STAGES=prepare,check ./virtualenv/bin/nosetests -v + RAGWEED_CONF=ragweed.conf RAGWEED_STAGES=prepare,check ./virtualenv/bin/pytest -v diff --git a/bootstrap b/bootstrap index 68d42f3..2abd2ea 100755 --- a/bootstrap +++ b/bootstrap @@ -34,7 +34,7 @@ virtualenv -p python3 --system-site-packages --download virtualenv # work-around change in pip 1.5 ./virtualenv/bin/pip install six -./virtualenv/bin/pip install -I nose +./virtualenv/bin/pip install -U pytest ./virtualenv/bin/pip install setuptools ./virtualenv/bin/pip install -U -r requirements.txt diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..48f2cbe --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_classes = r_test +python_files = test*.py diff --git a/ragweed/framework.py b/ragweed/framework.py index 3dfb3e4..a02d18e 100644 --- a/ragweed/framework.py +++ b/ragweed/framework.py @@ -15,6 +15,8 @@ import rados from .reqs import _make_admin_request +import pytest + ragweed_env = None suite = None @@ -287,7 +289,7 @@ class RZone: class RTest: - def __init__(self): + def setup_method(self): self._name = self.__class__.__name__ self.r_buckets = [] self.init() @@ -445,6 +447,7 @@ class RagweedEnv: 'ceph_conf is missing under the [rados] section in ' + os.environ['RAGWEED_CONF'] ) + print('conf=' + str(self.ceph_conf)) self.rados = rados.Rados(conffile=self.ceph_conf) self.rados.connect() @@ -459,3 +462,8 @@ def setup_module(): ragweed_env = RagweedEnv() suite = ragweed_env.suite + +@pytest.fixture(scope="package", autouse=True) +def setup_teardown(): + setup_module() + yield diff --git a/requirements.txt b/requirements.txt index 178ef67..b196d56 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ PyYAML -nose >=1.0.0 +pytest boto >=2.6.0, != 2.46.0 munch >=1.0.0 gevent >=1.0 -- 2.47.3