From 3a79fe754a2813ae4b7281c8add684c39cb5610d Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Sun, 9 Jan 2022 23:49:03 -0600 Subject: [PATCH] fixing tests --- test/test_networking.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/test_networking.py b/test/test_networking.py index 59591e96b9..a797c15a70 100644 --- a/test/test_networking.py +++ b/test/test_networking.py @@ -116,6 +116,8 @@ class TestFlagging(unittest.TestCase): callback = flagging.CSVLogger() callback.flag = mock.MagicMock() aiohttp.ClientSession.post = mock.MagicMock() + aiohttp.ClientSession.post.__aenter__ = None + aiohttp.ClientSession.post.__aexit__ = None io = Interface( lambda x: x, "text", "text", analytics_enabled=True, flagging_callback=callback) @@ -130,18 +132,20 @@ class TestFlagging(unittest.TestCase): io.close() -@mock.patch("aiohttp.ClientSession.post") class TestInterpretation(unittest.TestCase): - def test_interpretation(self, mock_post): + def test_interpretation(self): io = Interface( lambda x: len(x), "text", "label", interpretation="default", analytics_enabled=True) app, _, _ = io.launch(prevent_thread_lock=True) client = TestClient(app) + aiohttp.ClientSession.post = mock.MagicMock() + aiohttp.ClientSession.post.__aenter__ = None + aiohttp.ClientSession.post.__aexit__ = None io.interpret = mock.MagicMock(return_value=(None, None)) response = client.post( '/api/interpret/', json={"data": ["test test"]}) - mock_post.assert_called() + aiohttp.ClientSession.post.assert_called() self.assertEqual(response.status_code, 200) io.close()