From a2a75264c5c64f589ee9dc85b46461805ff11a3e Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 12 Oct 2022 14:06:40 -0400 Subject: [PATCH] cephadm: fix running test suite on python3.6 While a new version of pyfakefs is available, version 5 is not available for python 3.6. In order to run the test suite on centos 8 we will continue to work with pyfakefs version 4. Signed-off-by: John Mulligan (cherry picked from commit b5218528d63ae87ca77229bce1635c62411959e8) --- src/cephadm/tests/fixtures.py | 7 +++++-- src/cephadm/tox.ini | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cephadm/tests/fixtures.py b/src/cephadm/tests/fixtures.py index fffab9085f18c..1069b3823a7ae 100644 --- a/src/cephadm/tests/fixtures.py +++ b/src/cephadm/tests/fixtures.py @@ -69,8 +69,11 @@ def cephadm_fs( mock.patch('platform.processor', return_value='x86_64'), \ mock.patch('cephadm.extract_uid_gid', return_value=(uid, gid)): - if not fake_filesystem.is_root(): - fake_filesystem.set_uid(0) + try: + if not fake_filesystem.is_root(): + fake_filesystem.set_uid(0) + except AttributeError: + pass fs.create_dir(cd.DATA_DIR) fs.create_dir(cd.LOG_DIR) diff --git a/src/cephadm/tox.ini b/src/cephadm/tox.ini index c1d9cf6faf8f1..75758c068118d 100644 --- a/src/cephadm/tox.ini +++ b/src/cephadm/tox.ini @@ -33,7 +33,8 @@ addopts = [testenv] skip_install=true deps = - pyfakefs == 5.0 + pyfakefs == 4.5.6 ; python_version < "3.7" + pyfakefs >= 5, < 6 ; python_version >= "3.7" mock pytest commands=pytest {posargs} -- 2.39.5