Handle more warnings in tests

XMLWordPrintableJSON

    • Type: Build Failure
    • Resolution: Fixed
    • Priority: Unknown
    • 4.7
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We started treating warnings as errors in PYTHON-4014.

      We missed two:

      [2023/11/09 13:43:15.823] ImportError while loading conftest '/data/mci/77bc5c4ae245bc7787ae3f7cdad41abf/src/test/conftest.py'.
      [2023/11/09 13:43:15.953] test/__init__.py:45: in <module>
      [2023/11/09 13:43:15.953]     import pymongo
      [2023/11/09 13:43:15.953] pymongo/__init__.py:90: in <module>
      [2023/11/09 13:43:15.953]     from pymongo.collection import ReturnDocument
      [2023/11/09 13:43:15.953] pymongo/collection.py:43: in <module>
      [2023/11/09 13:43:15.953]     from pymongo import ASCENDING, _csot, common, helpers, message
      [2023/11/09 13:43:15.953] pymongo/common.py:43: in <module>
      [2023/11/09 13:43:15.953]     from pymongo.auth import MECHANISMS
      [2023/11/09 13:43:15.953] pymongo/auth.py:40: in <module>
      [2023/11/09 13:43:15.953]     from pymongo.auth_aws import _authenticate_aws
      [2023/11/09 13:43:15.953] pymongo/auth_aws.py:19: in <module>
      [2023/11/09 13:43:15.953]     import pymongo_auth_aws  # type:ignore[import]
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/pymongo_auth_aws/__init__.py:15: in <module>
      [2023/11/09 13:43:15.953]     from pymongo_auth_aws.auth import AwsCredential, AwsSaslContext
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/pymongo_auth_aws/auth.py:24: in <module>
      [2023/11/09 13:43:15.953]     import boto3
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/boto3/__init__.py:17: in <module>
      [2023/11/09 13:43:15.953]     from boto3.session import Session
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/boto3/session.py:17: in <module>
      [2023/11/09 13:43:15.953]     import botocore.session
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/botocore/session.py:26: in <module>
      [2023/11/09 13:43:15.953]     import botocore.client
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/botocore/client.py:15: in <module>
      [2023/11/09 13:43:15.953]     from botocore import waiter, xform_name
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/botocore/waiter.py:18: in <module>
      [2023/11/09 13:43:15.953]     from botocore.docs.docstring import WaiterDocstring
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/botocore/docs/__init__.py:15: in <module>
      [2023/11/09 13:43:15.953]     from botocore.docs.service import ServiceDocumenter
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/botocore/docs/service.py:13: in <module>
      [2023/11/09 13:43:15.953]     from botocore.docs.bcdoc.restdoc import DocumentStructure
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/botocore/docs/bcdoc/restdoc.py:17: in <module>
      [2023/11/09 13:43:15.953]     from botocore.compat import OrderedDict
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/botocore/compat.py:31: in <module>
      [2023/11/09 13:43:15.953]     from dateutil.tz import tzlocal
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/dateutil/tz/__init__.py:2: in <module>
      [2023/11/09 13:43:15.953]     from .tz import *
      [2023/11/09 13:43:15.953] .tox/test-eg/lib/python3.12/site-packages/dateutil/tz/tz.py:37: in <module>
      [2023/11/09 13:43:15.953]     EPOCH = datetime.datetime.utcfromtimestamp(0)
      [2023/11/09 13:43:15.953] E   DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
      

      https://spruce.mongodb.com/task/mongo_python_driver_tests_python_version_rhel8_test_encryption__platform~rhel8_auth_ssl~noauth_nossl_python_version~3.12_encryption~encryption_test_4.4_replica_set_578024e16af92dcdb4f4a871e257d46483aff58b_23_11_08_20_59_13/logs?execution=0&sortBy=STATUS&sortDir=ASC

      [2023/11/09 13:41:44.262] FAILURE: pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket object, fd=-1, family=2, type=1, proto=6>
       [2023/11/09 13:41:44.262] Traceback (most recent call last):
       [2023/11/09 13:41:44.262]   File "/data/mci/2ec2aa2295c8ae7d2d33b6b6f9c29f9e/src/bson/__init__.py", line 934, in _name_value_to_bson
       [2023/11/09 13:41:44.262]     marker = getattr(value, "_type_marker", None)
       [2023/11/09 13:41:44.262]              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [2023/11/09 13:41:44.262] ResourceWarning: unclosed <socket object, fd=19, family=2, type=1, proto=6> ()
       [2023/11/09 13:41:44.262] cls = <class '_pytest.runner.CallInfo'>
       [2023/11/09 13:41:44.262] func = <function call_runtest_hook.<locals>.<lambda> at 0x7f3508de65c0>
       [2023/11/09 13:41:44.262] when = 'call'
       [2023/11/09 13:41:44.262] reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)
       [2023/11/09 13:41:44.262]     @classmethod
       [2023/11/09 13:41:44.262]     def from_call(
       [2023/11/09 13:41:44.262]         cls,
       [2023/11/09 13:41:44.262]         func: "Callable[[], TResult]",
       [2023/11/09 13:41:44.262]         when: "Literal['collect', 'setup', 'call', 'teardown']",
       [2023/11/09 13:41:44.262]         reraise: Optional[
       [2023/11/09 13:41:44.262]             Union[Type[BaseException], Tuple[Type[BaseException], ...]]
       [2023/11/09 13:41:44.262]         ] = None,
       [2023/11/09 13:41:44.262]     ) -> "CallInfo[TResult]":
       [2023/11/09 13:41:44.262]         """Call func, wrapping the result in a CallInfo.
       [2023/11/09 13:41:44.262] 
       [2023/11/09 13:41:44.262]         :param func:
       [2023/11/09 13:41:44.262]             The function to call. Called without arguments.
       [2023/11/09 13:41:44.262]         :param when:
       [2023/11/09 13:41:44.262]             The phase in which the function is called.
       [2023/11/09 13:41:44.262]         :param reraise:
       [2023/11/09 13:41:44.262]             Exception or exceptions that shall propagate if raised by the
       [2023/11/09 13:41:44.262]             function, instead of being wrapped in the CallInfo.
       [2023/11/09 13:41:44.262]         """
       [2023/11/09 13:41:44.262]         excinfo = None
       [2023/11/09 13:41:44.262]         start = timing.time()
       [2023/11/09 13:41:44.262]         precise_start = timing.perf_counter()
       [2023/11/09 13:41:44.262]         try:
       [2023/11/09 13:41:44.262] >           result: Optional[TResult] = func()
       [2023/11/09 13:41:44.262] .tox/test-eg/lib/python3.12/site-packages/_pytest/runner.py:341:
       [2023/11/09 13:41:44.262] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
       [2023/11/09 13:41:44.262] .tox/test-eg/lib/python3.12/site-packages/_pytest/runner.py:262: in <lambda>
       [2023/11/09 13:41:44.262]     lambda: ihook(item=item, **kwds), when=when, reraise=reraise
       [2023/11/09 13:41:44.262] .tox/test-eg/lib/python3.12/site-packages/pluggy/_hooks.py:493: in __call__
       [2023/11/09 13:41:44.262]     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
       [2023/11/09 13:41:44.262] .tox/test-eg/lib/python3.12/site-packages/pluggy/_manager.py:115: in _hookexec
       [2023/11/09 13:41:44.262]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
       [2023/11/09 13:41:44.262] .tox/test-eg/lib/python3.12/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
       [2023/11/09 13:41:44.262]     yield from unraisable_exception_runtest_hook()
       [2023/11/09 13:41:44.262] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
       [2023/11/09 13:41:44.262]     def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
       [2023/11/09 13:41:44.262]         with catch_unraisable_exception() as cm:
       [2023/11/09 13:41:44.262]             yield
       [2023/11/09 13:41:44.262]             if cm.unraisable:
       [2023/11/09 13:41:44.262]                 if cm.unraisable.err_msg is not None:
       [2023/11/09 13:41:44.262]                     err_msg = cm.unraisable.err_msg
       [2023/11/09 13:41:44.262]                 else:
       [2023/11/09 13:41:44.262]                     err_msg = "Exception ignored in"
       [2023/11/09 13:41:44.262]                 msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
       [2023/11/09 13:41:44.262]                 msg += "".join(
       [2023/11/09 13:41:44.262]                     traceback.format_exception(
       [2023/11/09 13:41:44.262]                         cm.unraisable.exc_type,
       [2023/11/09 13:41:44.262]                         cm.unraisable.exc_value,
       [2023/11/09 13:41:44.262]                         cm.unraisable.exc_traceback,
       [2023/11/09 13:41:44.262]                     )
       [2023/11/09 13:41:44.262]                 )
       [2023/11/09 13:41:44.262] >               warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
       [2023/11/09 13:41:44.262] E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket object, fd=-1, family=2, type=1, proto=6>
       [2023/11/09 13:41:44.262] E
       [2023/11/09 13:41:44.262] E               Traceback (most recent call last):
       [2023/11/09 13:41:44.262] E                 File "/data/mci/2ec2aa2295c8ae7d2d33b6b6f9c29f9e/src/bson/__init__.py", line 934, in _name_value_to_bson
       [2023/11/09 13:41:44.262] E                   marker = getattr(value, "_type_marker", None)
       [2023/11/09 13:41:44.262] E                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       [2023/11/09 13:41:44.262] E               ResourceWarning: unclosed <socket object, fd=19, family=2, type=1, proto=6>
       [2023/11/09 13:41:44.262] .tox/test-eg/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning
      

      https://spruce.mongodb.com/task/mongo_python_driver_tests_python_version_green_framework_rhel8__platform~rhel8_auth_ssl~noauth_nossl_python_version~3.12_green_framework~gevent_test_4.0_replica_set_578024e16af92dcdb4f4a871e257d46483aff58b_23_11_08_20_59_13/tests?execution=0&sortBy=STATUS&sortDir=ASC

            Assignee:
            Steve Silvester
            Reporter:
            Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: