Skip to content

Commit

Permalink
Resolve failing unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Aug 24, 2022
1 parent 3166f40 commit 843148f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
14 changes: 10 additions & 4 deletions redis/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ async def connect(self):
lambda: self._connect(), lambda error: self.disconnect()
)
except asyncio.CancelledError:
raise
raise # is Exception and not BaseException in 3.7 and earlier
except (socket.timeout, asyncio.TimeoutError):
raise TimeoutError("Timeout connecting to server")
except OSError as e:
Expand Down Expand Up @@ -906,7 +906,9 @@ async def send_packed_command(
raise ConnectionError(
f"Error {err_no} while writing to socket. {errmsg}."
) from e
except BaseException:
except asyncio.CancelledError:
raise # is Exception and not BaseException in 3.7 and earlier
except Exception:
await self.disconnect()
raise

Expand Down Expand Up @@ -949,7 +951,9 @@ async def read_response(self, disable_decoding: bool = False):
raise ConnectionError(
f"Error while reading from {self.host}:{self.port} : {e.args}"
)
except BaseException:
except asyncio.CancelledError:
raise # is Exception and not BaseException in 3.7 and earlier
except Exception:
await self.disconnect()
raise

Expand Down Expand Up @@ -981,7 +985,9 @@ async def read_response_without_lock(self, disable_decoding: bool = False):
raise ConnectionError(
f"Error while reading from {self.host}:{self.port} : {e.args}"
)
except BaseException:
except asyncio.CancelledError:
raise # is Exception and not BaseException in 3.7 and earlier
except Exception:
await self.disconnect()
raise

Expand Down
4 changes: 2 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ def send_packed_command(self, command, check_health=True):
errno = e.args[0]
errmsg = e.args[1]
raise ConnectionError(f"Error {errno} while writing to socket. {errmsg}.")
except BaseException:
except Exception:
self.disconnect()
raise

Expand Down Expand Up @@ -828,7 +828,7 @@ def read_response(self, disable_decoding=False):
except OSError as e:
self.disconnect()
raise ConnectionError(f"Error while reading from {hosterr}" f" : {e.args}")
except BaseException:
except Exception:
self.disconnect()
raise

Expand Down
1 change: 0 additions & 1 deletion tests/test_asyncio/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,6 @@ async def loop_step_listen(self):
return False


@pytest.mark.xfail
@pytest.mark.onlynoncluster
class TestBaseException:
@pytest.mark.skipif(
Expand Down
1 change: 0 additions & 1 deletion tests/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ def loop_step_listen(self):
return True


@pytest.mark.xfail
@pytest.mark.onlynoncluster
class TestBaseException:
def test_base_exception(self, r: redis.Redis):
Expand Down

0 comments on commit 843148f

Please sign in to comment.