prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Log message hiding interfers with pytest log caputure fixture.
  The log message hiding merged in #1535 interferes with pytests log capturing. 
  
  In the example below I am using the [caplog fixture](https://docs.pytest.org/en/latest/logging.html#caplog-fixture) to capture the log message and test that they are correct.
  In this simple case just asserting the number of messages. This results in an empty record list in the first call with  3.69.11 but works as expected with 3.69.10
  
  ```python
  import logging
  from hypothesis import given, strategies
  
  @given(x=strategies.floats(min_value=-3, max_value=3))
  def test_logcapture(x, caplog):
  
      with caplog.at_level(logging.CRITICAL, logger='root'):
          caplog.clear()
          logging.critical(f"x is {x}")
      assert len(caplog.records) == 1 
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `hypothesis-python/src/hypothesis/control.py`
  Content:
  ```
  1 # coding=utf-8
  2 #
  3 # This file is part of Hypothesis, which may be found at
  4 # https://github.com/HypothesisWorks/hypothesis-python
  5 #
  6 # Most of this work is copyright (C) 2013-2018 David R. MacIver
  7 # (david@drmaciver.com), but it contains contributions by others. See
  8 # CONTRIBUTING.rst for a full list of people who may hold copyright, and
  9 # consult the git log if you need to determine who owns an individual
  10 # contribution.
  11 #
  12 # This Source Code Form is subject to the terms of the Mozilla Public License,
  13 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
  14 # obtain one at http://mozilla.org/MPL/2.0/.
  15 #
  16 # END HEADER
  17 
  18 from __future__ import division, print_function, absolute_import
  19 
  20 import logging
  21 import traceback
  22 
  23 from hypothesis import Verbosity, settings
  24 from hypothesis.errors import CleanupFailed, InvalidArgument, \
  25     UnsatisfiedAssumption
  26 from hypothesis.reporting import report
  27 from hypothesis.utils.dynamicvariables import DynamicVariable
  28 
  29 if False:
  30     from typing import Any, AnyStr  # noqa
  31 
  32 
  33 def reject():
  34     raise UnsatisfiedAssumption()
  35 
  36 
  37 def assume(condition):
  38     # type: (Any) -> bool
  39     """Calling ``assume`` is like an :ref:`assert <python:assert>` that marks
  40     the example as bad, rather than failing the test.
  41 
  42     This allows you to specify properties that you *assume* will be
  43     true, and let Hypothesis try to avoid similar examples in future.
  44     """
  45     if not condition:
  46         raise UnsatisfiedAssumption()
  47     return True
  48 
  49 
  50 _current_build_context = DynamicVariable(None)
  51 
  52 
  53 def current_build_context():
  54     context = _current_build_context.value
  55     if context is None:
  56         raise InvalidArgument(
  57             u'No build context registered')
  58     return context
  59 
  60 
  61 class BuildContext(object):
  62 
  63     def __init__(self, data, is_final=False, close_on_capture=True):
  64         self.data = data
  65         self.tasks = []
  66         self.is_final = is_final
  67         self.close_on_capture = close_on_capture
  68         self.close_on_del = False
  69         self.notes = []
  70         self.original_logging_disable = logging.NOTSET
  71 
  72     def __enter__(self):
  73         if not self.is_final:
  74             self.original_logging_disable = logging.root.manager.disable
  75             logging.disable(logging.CRITICAL)
  76         self.assign_variable = _current_build_context.with_value(self)
  77         self.assign_variable.__enter__()
  78         return self
  79 
  80     def __exit__(self, exc_type, exc_value, tb):
  81         self.assign_variable.__exit__(exc_type, exc_value, tb)
  82         if not self.is_final:
  83             logging.disable(self.original_logging_disable)
  84         if self.close() and exc_type is None:
  85             raise CleanupFailed()
  86 
  87     def local(self):
  88         return _current_build_context.with_value(self)
  89 
  90     def close(self):
  91         any_failed = False
  92         for task in self.tasks:
  93             try:
  94                 task()
  95             except BaseException:
  96                 any_failed = True
  97                 report(traceback.format_exc())
  98         return any_failed
  99 
  100 
  101 def cleanup(teardown):
  102     """Register a function to be called when the current test has finished
  103     executing. Any exceptions thrown in teardown will be printed but not
  104     rethrown.
  105 
  106     Inside a test this isn't very interesting, because you can just use
  107     a finally block, but note that you can use this inside map, flatmap,
  108     etc. in order to e.g. insist that a value is closed at the end.
  109     """
  110     context = _current_build_context.value
  111     if context is None:
  112         raise InvalidArgument(
  113             u'Cannot register cleanup outside of build context')
  114     context.tasks.append(teardown)
  115 
  116 
  117 def note(value):
  118     # type: (AnyStr) -> None
  119     """Report this value in the final execution."""
  120     context = _current_build_context.value
  121     if context is None:
  122         raise InvalidArgument(
  123             'Cannot make notes outside of a test')
  124     context.notes.append(value)
  125     if context.is_final or settings.default.verbosity >= Verbosity.verbose:
  126         report(value)
  127 
  128 
  129 def event(value):
  130     # type: (AnyStr) -> None
  131     """Record an event that occurred this test. Statistics on number of test
  132     runs with each event will be reported at the end if you run Hypothesis in
  133     statistics reporting mode.
  134 
  135     Events should be strings or convertible to them.
  136     """
  137     context = _current_build_context.value
  138     if context is None:
  139         raise InvalidArgument(
  140             'Cannot make record events outside of a test')
  141 
  142     if context.data is not None:
  143         context.data.note_event(value)
  144
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/hypothesis-python/src/hypothesis/control.py b/hypothesis-python/src/hypothesis/control.py
  --- a/hypothesis-python/src/hypothesis/control.py
  +++ b/hypothesis-python/src/hypothesis/control.py
  @@ -17,7 +17,6 @@
   
   from __future__ import division, print_function, absolute_import
   
  -import logging
   import traceback
   
   from hypothesis import Verbosity, settings
  @@ -67,20 +66,14 @@
           self.close_on_capture = close_on_capture
           self.close_on_del = False
           self.notes = []
  -        self.original_logging_disable = logging.NOTSET
   
       def __enter__(self):
  -        if not self.is_final:
  -            self.original_logging_disable = logging.root.manager.disable
  -            logging.disable(logging.CRITICAL)
           self.assign_variable = _current_build_context.with_value(self)
           self.assign_variable.__enter__()
           return self
   
       def __exit__(self, exc_type, exc_value, tb):
           self.assign_variable.__exit__(exc_type, exc_value, tb)
  -        if not self.is_final:
  -            logging.disable(self.original_logging_disable)
           if self.close() and exc_type is None:
               raise CleanupFailed()
  
verification_info: {"golden_diff": "diff --git a/hypothesis-python/src/hypothesis/control.py b/hypothesis-python/src/hypothesis/control.py\n--- a/hypothesis-python/src/hypothesis/control.py\n+++ b/hypothesis-python/src/hypothesis/control.py\n@@ -17,7 +17,6 @@\n \n from __future__ import division, print_function, absolute_import\n \n-import logging\n import traceback\n \n from hypothesis import Verbosity, settings\n@@ -67,20 +66,14 @@\n         self.close_on_capture = close_on_capture\n         self.close_on_del = False\n         self.notes = []\n-        self.original_logging_disable = logging.NOTSET\n \n     def __enter__(self):\n-        if not self.is_final:\n-            self.original_logging_disable = logging.root.manager.disable\n-            logging.disable(logging.CRITICAL)\n         self.assign_variable = _current_build_context.with_value(self)\n         self.assign_variable.__enter__()\n         return self\n \n     def __exit__(self, exc_type, exc_value, tb):\n         self.assign_variable.__exit__(exc_type, exc_value, tb)\n-        if not self.is_final:\n-            logging.disable(self.original_logging_disable)\n         if self.close() and exc_type is None:\n             raise CleanupFailed()\n", "issue": "Log message hiding interfers with pytest log caputure fixture.\nThe log message hiding merged in #1535 interferes with pytests log capturing. \r\n\r\nIn the example below I am using the [caplog fixture](https://docs.pytest.org/en/latest/logging.html#caplog-fixture) to capture the log message and test that they are correct.\r\nIn this simple case just asserting the number of messages. This results in an empty record list in the first call with  3.69.11 but works as expected with 3.69.10\r\n\r\n```python\r\nimport logging\r\nfrom hypothesis import given, strategies\r\n\r\n@given(x=strategies.floats(min_value=-3, max_value=3))\r\ndef test_logcapture(x, caplog):\r\n\r\n    with caplog.at_level(logging.CRITICAL, logger='root'):\r\n        caplog.clear()\r\n        logging.critical(f\"x is {x}\")\r\n    assert len(caplog.records) == 1 \r\n```\n", "before_files": [{"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2018 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\nimport logging\nimport traceback\n\nfrom hypothesis import Verbosity, settings\nfrom hypothesis.errors import CleanupFailed, InvalidArgument, \\\n    UnsatisfiedAssumption\nfrom hypothesis.reporting import report\nfrom hypothesis.utils.dynamicvariables import DynamicVariable\n\nif False:\n    from typing import Any, AnyStr  # noqa\n\n\ndef reject():\n    raise UnsatisfiedAssumption()\n\n\ndef assume(condition):\n    # type: (Any) -> bool\n    \"\"\"Calling ``assume`` is like an :ref:`assert <python:assert>` that marks\n    the example as bad, rather than failing the test.\n\n    This allows you to specify properties that you *assume* will be\n    true, and let Hypothesis try to avoid similar examples in future.\n    \"\"\"\n    if not condition:\n        raise UnsatisfiedAssumption()\n    return True\n\n\n_current_build_context = DynamicVariable(None)\n\n\ndef current_build_context():\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            u'No build context registered')\n    return context\n\n\nclass BuildContext(object):\n\n    def __init__(self, data, is_final=False, close_on_capture=True):\n        self.data = data\n        self.tasks = []\n        self.is_final = is_final\n        self.close_on_capture = close_on_capture\n        self.close_on_del = False\n        self.notes = []\n        self.original_logging_disable = logging.NOTSET\n\n    def __enter__(self):\n        if not self.is_final:\n            self.original_logging_disable = logging.root.manager.disable\n            logging.disable(logging.CRITICAL)\n        self.assign_variable = _current_build_context.with_value(self)\n        self.assign_variable.__enter__()\n        return self\n\n    def __exit__(self, exc_type, exc_value, tb):\n        self.assign_variable.__exit__(exc_type, exc_value, tb)\n        if not self.is_final:\n            logging.disable(self.original_logging_disable)\n        if self.close() and exc_type is None:\n            raise CleanupFailed()\n\n    def local(self):\n        return _current_build_context.with_value(self)\n\n    def close(self):\n        any_failed = False\n        for task in self.tasks:\n            try:\n                task()\n            except BaseException:\n                any_failed = True\n                report(traceback.format_exc())\n        return any_failed\n\n\ndef cleanup(teardown):\n    \"\"\"Register a function to be called when the current test has finished\n    executing. Any exceptions thrown in teardown will be printed but not\n    rethrown.\n\n    Inside a test this isn't very interesting, because you can just use\n    a finally block, but note that you can use this inside map, flatmap,\n    etc. in order to e.g. insist that a value is closed at the end.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            u'Cannot register cleanup outside of build context')\n    context.tasks.append(teardown)\n\n\ndef note(value):\n    # type: (AnyStr) -> None\n    \"\"\"Report this value in the final execution.\"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            'Cannot make notes outside of a test')\n    context.notes.append(value)\n    if context.is_final or settings.default.verbosity >= Verbosity.verbose:\n        report(value)\n\n\ndef event(value):\n    # type: (AnyStr) -> None\n    \"\"\"Record an event that occurred this test. Statistics on number of test\n    runs with each event will be reported at the end if you run Hypothesis in\n    statistics reporting mode.\n\n    Events should be strings or convertible to them.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            'Cannot make record events outside of a test')\n\n    if context.data is not None:\n        context.data.note_event(value)\n", "path": "hypothesis-python/src/hypothesis/control.py"}], "after_files": [{"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2018 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\nimport traceback\n\nfrom hypothesis import Verbosity, settings\nfrom hypothesis.errors import CleanupFailed, InvalidArgument, \\\n    UnsatisfiedAssumption\nfrom hypothesis.reporting import report\nfrom hypothesis.utils.dynamicvariables import DynamicVariable\n\nif False:\n    from typing import Any, AnyStr  # noqa\n\n\ndef reject():\n    raise UnsatisfiedAssumption()\n\n\ndef assume(condition):\n    # type: (Any) -> bool\n    \"\"\"Calling ``assume`` is like an :ref:`assert <python:assert>` that marks\n    the example as bad, rather than failing the test.\n\n    This allows you to specify properties that you *assume* will be\n    true, and let Hypothesis try to avoid similar examples in future.\n    \"\"\"\n    if not condition:\n        raise UnsatisfiedAssumption()\n    return True\n\n\n_current_build_context = DynamicVariable(None)\n\n\ndef current_build_context():\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            u'No build context registered')\n    return context\n\n\nclass BuildContext(object):\n\n    def __init__(self, data, is_final=False, close_on_capture=True):\n        self.data = data\n        self.tasks = []\n        self.is_final = is_final\n        self.close_on_capture = close_on_capture\n        self.close_on_del = False\n        self.notes = []\n\n    def __enter__(self):\n        self.assign_variable = _current_build_context.with_value(self)\n        self.assign_variable.__enter__()\n        return self\n\n    def __exit__(self, exc_type, exc_value, tb):\n        self.assign_variable.__exit__(exc_type, exc_value, tb)\n        if self.close() and exc_type is None:\n            raise CleanupFailed()\n\n    def local(self):\n        return _current_build_context.with_value(self)\n\n    def close(self):\n        any_failed = False\n        for task in self.tasks:\n            try:\n                task()\n            except BaseException:\n                any_failed = True\n                report(traceback.format_exc())\n        return any_failed\n\n\ndef cleanup(teardown):\n    \"\"\"Register a function to be called when the current test has finished\n    executing. Any exceptions thrown in teardown will be printed but not\n    rethrown.\n\n    Inside a test this isn't very interesting, because you can just use\n    a finally block, but note that you can use this inside map, flatmap,\n    etc. in order to e.g. insist that a value is closed at the end.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            u'Cannot register cleanup outside of build context')\n    context.tasks.append(teardown)\n\n\ndef note(value):\n    # type: (AnyStr) -> None\n    \"\"\"Report this value in the final execution.\"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            'Cannot make notes outside of a test')\n    context.notes.append(value)\n    if context.is_final or settings.default.verbosity >= Verbosity.verbose:\n        report(value)\n\n\ndef event(value):\n    # type: (AnyStr) -> None\n    \"\"\"Record an event that occurred this test. Statistics on number of test\n    runs with each event will be reported at the end if you run Hypothesis in\n    statistics reporting mode.\n\n    Events should be strings or convertible to them.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            'Cannot make record events outside of a test')\n\n    if context.data is not None:\n        context.data.note_event(value)\n", "path": "hypothesis-python/src/hypothesis/control.py"}]}