diff --git a/setup.py b/setup.py index fcc74aa6..1e5387bf 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,6 @@ "pandas": ["pandas>=0.21.1"], "fastavro": ["fastavro>=0.21.2"], "pyarrow": ["pyarrow>=0.15.0"], - "tests": ["freezegun"], } package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/tests/unit/test_writer_v1.py b/tests/unit/test_writer_v1.py index 1ef51320..9ecb1858 100644 --- a/tests/unit/test_writer_v1.py +++ b/tests/unit/test_writer_v1.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time from unittest import mock -import freezegun import pytest from google.api_core import exceptions @@ -128,10 +128,11 @@ def test_initial_send_with_timeout(background_consumer, bidi_rpc, module_under_t initial_request = gapic_types.AppendRowsRequest( write_stream="this-is-a-stream-resource-path" ) - - with pytest.raises(exceptions.Unknown), freezegun.freeze_time( - auto_tick_seconds=module_under_test._DEFAULT_TIMEOUT + 1 - ): + now = time.monotonic() + later = now + module_under_test._DEFAULT_TIMEOUT + 1 + with mock.patch.object(module_under_test.time, "sleep"), mock.patch.object( + module_under_test.time, "monotonic", mock.MagicMock(side_effect=(now, later)) + ), pytest.raises(exceptions.Unknown): manager.send(initial_request) diff --git a/tests/unit/test_writer_v1beta2.py b/tests/unit/test_writer_v1beta2.py index 66d01fe0..15fc8c8a 100644 --- a/tests/unit/test_writer_v1beta2.py +++ b/tests/unit/test_writer_v1beta2.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time from unittest import mock -import freezegun import pytest from google.api_core import exceptions @@ -129,9 +129,11 @@ def test_initial_send_with_timeout(background_consumer, bidi_rpc, module_under_t write_stream="this-is-a-stream-resource-path" ) - with pytest.raises(exceptions.Unknown), freezegun.freeze_time( - auto_tick_seconds=module_under_test._DEFAULT_TIMEOUT + 1 - ): + now = time.monotonic() + later = now + module_under_test._DEFAULT_TIMEOUT + 1 + with mock.patch.object(module_under_test.time, "sleep"), mock.patch.object( + module_under_test.time, "monotonic", mock.MagicMock(side_effect=(now, later)) + ), pytest.raises(exceptions.Unknown): manager.send(initial_request)