...
 
Commits (2)
Copyright (c) 2016, Tim Stumbaugh
Copyright (c) 2018, Tim Stumbaugh
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
# -*- coding: utf-8 -*-
# rediparse from https://gitlab.com/tjstum/rediparse/
# Copyright (c) 2018, Tim Stumbaugh
# All rights reserved.
# This project is licensed under the BSD 3-clause "New" or "Revised" License.
from io import BytesIO
from typing import Union, Sequence
from collections import deque
......
......@@ -5,7 +5,7 @@ Custom tests for PythonReader and rediparse in general
The tests for this package consist of this module in addition to test_like_hiredis.py
"""
from rediparse import PythonReader, ReplyError, BestReader
from rediparse import PythonReader, ReplyError, BestReader, ProtocolError
import pytest
@pytest.fixture
......@@ -78,6 +78,13 @@ def test_disabled_encoding():
reader.feed(b"+ok\r\n")
assert reader.gets() == b"ok"
def test_violating_bulk_string(basic_reader):
basic_reader.feed(b"$2\r\nhi")
assert basic_reader.gets() is False
basic_reader.feed(b"\x00\x00")
with pytest.raises(ProtocolError):
basic_reader.gets()
# These tests may be slightly confusing, but the goal is to have tests that provide
# adequate coverage despite the presence or lack thereof of hiredis. See this handy chart:
# | hiredis | test_hiredis_fallback | test_hiredis_available | test_hiredis_not_installed |
......