On Wed, Mar 13, 2024 at 03:57:06PM +0100, Lucas Nussbaum wrote:
> > =================================== FAILURES
> > ===================================
> > ___________________ TestUtils.test_init_once_and_debug_mode
> > ____________________
> >
> > self = <libcloud.test.test_init.TestUtils
> > testMethod=test_init_once_and_debug_mode>
> >
> > def test_init_once_and_debug_mode(self):
> > if have_paramiko:
> > paramiko_logger = logging.getLogger('paramiko')
> > paramiko_logger.setLevel(logging.INFO)
> >
> > # Debug mode is disabled
> > _init_once()
> >
> > > self.assertIsNone(LoggingConnection.log)
> > E AssertionError: <codecs.StreamReaderWriter object at
> > 0x7f79cb14b090> is not None
> >
> > libcloud/test/test_init.py:50: AssertionError
This seems to be an issue with the upstream test suite and is caused by
_init_once() having already been called earlier in the test execution process.
If we run just the failing test on its own, it is successful, but if we run
tests in libcloud/test/compute/test_ssh_client.py first, then it fails because
its setup method calls _init_once(). See below for logs indicating this
behavior. I'm not sure of the best way to avoid this. Can we somehow
undo the effect of _init_once()? Or force these tests to run in a
separate process? Someone who knows pytest better than me might have
ideas...
Note that this issue is still present in the libcloud 3.8.0 currently in
git.
Successful standalone test execution:
builder@b6dfde9f3b55:/src/libcloud/.pybuild/cpython3_3.11_libcloud/build$
python3 -m pytest libcloud/test/test_init.py -v
==================================================== test session starts
====================================================
platform linux -- Python 3.11.9, pytest-8.1.2, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False
min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10
warmup=False warmup_iterations=100000)
rootdir: /src/libcloud/.pybuild/cpython3_3.11_libcloud/build
configfile: pyproject.toml
plugins: xdist-3.5.0, benchmark-4.0.0, timeout-2.3.1, requests-mock-1.11.0
collected 5 items
libcloud/test/test_init.py::TestUtils::test_factory PASSED
[ 20%]
libcloud/test/test_init.py::TestUtils::test_init_once_and_debug_mode PASSED
[ 40%]
libcloud/test/test_init.py::TestUtils::test_init_once_correct_chardet_version
PASSED [ 60%]
libcloud/test/test_init.py::TestUtils::test_init_once_detects_bad_yum_install_requests
PASSED [ 80%]
libcloud/test/test_init.py::TestUtils::test_raises_error PASSED
[100%]
=================================================== slowest 10 durations
====================================================
0.01s call libcloud/test/test_init.py::TestUtils::test_factory
(9 durations < 0.005s hidden. Use -vv to show these durations.)
===================================================== 5 passed in 0.11s
=====================================================
Failing execution following execution of a test from
libcloud/test/compute/test_ssh_client.py:
libcloud/test/compute/test_ssh_client.py::ParamikoSSHClientTests::test_key_material_valid_pem_keys_invalid_header_auto_converbuilder@b6dfde9f3b55:/src/libcloud/.pybuild/cpython3_3.11_libcloud/build$
python3 -m pytest
libcloud/test/compute/test_ssh_client.py::ParamikoSSHClientTests::test_password_protected_key_valid_password_provided
libcloud/test/test_init.py -v
==================================================== test session starts
====================================================
platform linux -- Python 3.11.9, pytest-8.1.2, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False
min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10
warmup=False warmup_iterations=100000)
rootdir: /src/libcloud/.pybuild/cpython3_3.11_libcloud/build
configfile: pyproject.toml
plugins: xdist-3.5.0, benchmark-4.0.0, timeout-2.3.1, requests-mock-1.11.0
collected 6 items
libcloud/test/compute/test_ssh_client.py::ParamikoSSHClientTests::test_password_protected_key_valid_password_provided
PASSED [ 16%]
libcloud/test/test_init.py::TestUtils::test_factory PASSED
[ 33%]
libcloud/test/test_init.py::TestUtils::test_init_once_and_debug_mode FAILED
[ 50%]
libcloud/test/test_init.py::TestUtils::test_init_once_correct_chardet_version
PASSED [ 66%]
libcloud/test/test_init.py::TestUtils::test_init_once_detects_bad_yum_install_requests
PASSED [ 83%]
libcloud/test/test_init.py::TestUtils::test_raises_error PASSED
[100%]
========================================================= FAILURES
==========================================================
__________________________________________
TestUtils.test_init_once_and_debug_mode
__________________________________________
self = <libcloud.test.test_init.TestUtils
testMethod=test_init_once_and_debug_mode>
def test_init_once_and_debug_mode(self):
if have_paramiko:
paramiko_logger = logging.getLogger("paramiko")
paramiko_logger.setLevel(logging.INFO)
# Debug mode is disabled
_init_once()
> self.assertIsNone(LoggingConnection.log)
E AssertionError: <codecs.StreamReaderWriter object at 0x7f12de4a3410> is
not None
libcloud/test/test_init.py:49: AssertionError
===================================================== warnings summary
======================================================
libcloud/test/compute/test_ssh_client.py::ParamikoSSHClientTests::test_password_protected_key_valid_password_provided
/src/libcloud/.pybuild/cpython3_3.11_libcloud/build/libcloud/compute/ssh.py:147:
DeprecationWarning: You are using deprecated "key" argument which has been
replaced with "key_files" argument
warnings.warn(message, DeprecationWarning)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=================================================== slowest 10 durations
====================================================
0.41s call
libcloud/test/compute/test_ssh_client.py::ParamikoSSHClientTests::test_password_protected_key_valid_password_provided
(9 durations < 0.005s hidden. Use -vv to show these durations.)
================================================== short test summary info
==================================================
FAILED libcloud/test/test_init.py::TestUtils::test_init_once_and_debug_mode -
AssertionError: <codecs.StreamReaderWriter object at 0x7f12de4a3410> is not None
========================================== 1 failed, 5 passed, 1 warning in
0.56s ===========================================