File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 55from collections import deque
66
77from arango .exceptions import (
8- CursorNextError ,
98 CursorCloseError ,
9+ CursorEmptyError ,
10+ CursorNextError ,
1011 CursorStateError ,
11- CursorEmptyError
12+ CursorCountError
1213)
1314from arango .request import Request
1415
@@ -63,6 +64,8 @@ def __enter__(self):
6364 return self
6465
6566 def __len__ (self ):
67+ if self ._count is None :
68+ raise CursorCountError ('cursor count not enabled' )
6669 return self ._count
6770
6871 def __exit__ (self , * _ ):
Original file line number Diff line number Diff line change @@ -266,6 +266,10 @@ class CursorStateError(ArangoClientError):
266266 """The cursor object was in a bad state."""
267267
268268
269+ class CursorCountError (ArangoClientError , TypeError ):
270+ """The cursor count was not enabled."""
271+
272+
269273class CursorEmptyError (ArangoClientError ):
270274 """The current batch in cursor was empty."""
271275
Original file line number Diff line number Diff line change 44
55from arango .exceptions import (
66 CursorCloseError ,
7+ CursorCountError ,
78 CursorEmptyError ,
89 CursorNextError ,
910 CursorStateError ,
@@ -270,6 +271,22 @@ def test_cursor_no_count(db, col):
270271 optimizer_rules = ['+all' ],
271272 profile = True
272273 )
274+ with pytest .raises (CursorCountError ) as err :
275+ _ = len (cursor )
276+ assert err .value .message == 'cursor count not enabled'
277+
278+ with pytest .raises (CursorCountError ) as err :
279+ _ = bool (cursor )
280+ assert err .value .message == 'cursor count not enabled'
281+
273282 while cursor .has_more ():
274283 assert cursor .count () is None
284+
285+ with pytest .raises (CursorCountError ) as err :
286+ _ = len (cursor )
287+ assert err .value .message == 'cursor count not enabled'
288+
289+ with pytest .raises (CursorCountError ) as err :
290+ _ = bool (cursor )
291+ assert err .value .message == 'cursor count not enabled'
275292 assert cursor .fetch ()
You can’t perform that action at this time.
0 commit comments