Fix flush exception thrown when LoggerProvider not configured by iurisilvio · Pull Request #3608 · open-telemetry/opentelemetry-python

py311-opentelemetry-sdk: commands[0] /home/tigre/github/ocelotl/opentelemetry-python/opentelemetry-sdk/tests> pytest -k test_log_flush_noop -s -v -rf
===================================================================================== test session starts ======================================================================================
platform linux -- Python 3.11.2, pytest-7.1.3, pluggy-1.4.0 -- /home/tigre/github/ocelotl/opentelemetry-python/.tox/py311-opentelemetry-sdk/bin/python
cachedir: .tox/py311-opentelemetry-sdk/.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: /home/tigre/github/ocelotl/opentelemetry-python, configfile: pyproject.toml
plugins: flaky-3.7.0, benchmark-4.0.0
collected 491 items / 490 deselected / 1 selected                                                                                                                                              

logs/test_handler.py::TestLoggingHandler::test_log_flush_noop PASSED

============================================================================== 1 passed, 490 deselected in 0.27s ===============================================================================
Exception ignored in atexit callback: <function shutdown at 0x7f519fff3240>
Traceback (most recent call last):
  File "/home/tigre/.pyenv/versions/3.11.2/lib/python3.11/logging/__init__.py", line 2192, in shutdown
    h.flush()
  File "/home/tigre/github/ocelotl/opentelemetry-python/.tox/py311-opentelemetry-sdk/lib/python3.11/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 559, in flush
    self._logger_provider.force_flush()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tigre/.pyenv/versions/3.11.2/lib/python3.11/unittest/mock.py", line 647, in __getattr__
    raise AttributeError("Mock object has no attribute %r" % name)
AttributeError: Mock object has no attribute 'force_flush'
  py311-opentelemetry-sdk: OK (10.91=setup[0.04]+cmd[1.41,8.91,0.55] seconds)
  congratulations :) (11.01 seconds)