Skip to content

Commit 04f340e

Browse files
committed
Resolve failing unittest
1 parent f4c1afa commit 04f340e

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

redis/asyncio/connection.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ async def connect(self):
711711
lambda: self._connect(), lambda error: self.disconnect()
712712
)
713713
except asyncio.CancelledError:
714-
raise
714+
raise # is Exception and not BaseException in 3.7 and earlier
715715
except (socket.timeout, asyncio.TimeoutError):
716716
raise TimeoutError("Timeout connecting to server")
717717
except OSError as e:
@@ -906,7 +906,9 @@ async def send_packed_command(
906906
raise ConnectionError(
907907
f"Error {err_no} while writing to socket. {errmsg}."
908908
) from e
909-
except BaseException:
909+
except asyncio.CancelledError:
910+
raise # is Exception and not BaseException in 3.7 and earlier
911+
except Exception:
910912
await self.disconnect()
911913
raise
912914

@@ -949,7 +951,9 @@ async def read_response(self, disable_decoding: bool = False):
949951
raise ConnectionError(
950952
f"Error while reading from {self.host}:{self.port} : {e.args}"
951953
)
952-
except BaseException:
954+
except asyncio.CancelledError:
955+
raise # is Exception and not BaseException in 3.7 and earlier
956+
except Exception:
953957
await self.disconnect()
954958
raise
955959

@@ -981,7 +985,9 @@ async def read_response_without_lock(self, disable_decoding: bool = False):
981985
raise ConnectionError(
982986
f"Error while reading from {self.host}:{self.port} : {e.args}"
983987
)
984-
except BaseException:
988+
except asyncio.CancelledError:
989+
raise # is Exception and not BaseException in 3.7 and earlier
990+
except Exception:
985991
await self.disconnect()
986992
raise
987993

redis/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def send_packed_command(self, command, check_health=True):
790790
errno = e.args[0]
791791
errmsg = e.args[1]
792792
raise ConnectionError(f"Error {errno} while writing to socket. {errmsg}.")
793-
except BaseException:
793+
except Exception:
794794
self.disconnect()
795795
raise
796796

@@ -828,7 +828,7 @@ def read_response(self, disable_decoding=False):
828828
except OSError as e:
829829
self.disconnect()
830830
raise ConnectionError(f"Error while reading from {hosterr}" f" : {e.args}")
831-
except BaseException:
831+
except Exception:
832832
self.disconnect()
833833
raise
834834

tests/test_asyncio/test_pubsub.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ async def loop_step_listen(self):
918918
return False
919919

920920

921-
@pytest.mark.xfail
922921
@pytest.mark.onlynoncluster
923922
class TestBaseException:
924923
@pytest.mark.skipif(

tests/test_pubsub.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,6 @@ def loop_step_listen(self):
737737
return True
738738

739739

740-
@pytest.mark.xfail
741740
@pytest.mark.onlynoncluster
742741
class TestBaseException:
743742
def test_base_exception(self, r: redis.Redis):

0 commit comments

Comments
 (0)