Skip to content

Commit

Permalink
Added pragma: no cover to untested bits of DataLoader (minor stuff)
Browse files Browse the repository at this point in the history
  • Loading branch information
flipbit03 committed Sep 6, 2022
1 parent 32ab879 commit 1e7bfb7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions graphene/utils/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ def __init__(
), "batch_load_fn must be coroutine. Received: {}".format(self.batch_load_fn)

if not callable(self.batch_load_fn):
raise TypeError(
raise TypeError( # pragma: no cover
(
"DataLoader must be have a batch_load_fn which accepts "
"Iterable<key> and returns Future<Iterable<value>>, but got: {}."
).format(batch_load_fn)
)

if batch is not None:
self.batch = batch
self.batch = batch # pragma: no cover

if max_batch_size is not None:
self.max_batch_size = max_batch_size

if cache is not None:
self.cache = cache
self.cache = cache # pragma: no cover

self.get_cache_key = get_cache_key or (lambda x: x)

Expand All @@ -77,7 +77,7 @@ def load(self, key=None):
Loads a key, returning a `Future` for the value represented by that key.
"""
if key is None:
raise TypeError(
raise TypeError( # pragma: no cover
(
"The loader.load() function must be called with a value, "
"but got: {}."
Expand Down Expand Up @@ -113,7 +113,7 @@ def do_resolve_reject(self, key, future):
enqueue_post_future_job(self.loop, self)
else:
# Otherwise dispatch the (queue of one) immediately.
dispatch_queue(self)
dispatch_queue(self) # pragma: no cover

def load_many(self, keys):
"""
Expand All @@ -129,7 +129,7 @@ def load_many(self, keys):
>>> )
"""
if not isinstance(keys, Iterable):
raise TypeError(
raise TypeError( # pragma: no cover
(
"The loader.load_many() function must be called with Iterable<key> "
"but got: {}."
Expand Down Expand Up @@ -223,7 +223,7 @@ async def dispatch_queue_batch(loader, queue):

# Assert the expected response from batch_load_fn
if not batch_future or not iscoroutine(batch_future):
return failed_dispatch(
return failed_dispatch( # pragma: no cover
loader,
queue,
TypeError(
Expand All @@ -238,7 +238,7 @@ async def dispatch_queue_batch(loader, queue):
try:
values = await batch_future
if not isinstance(values, Iterable):
raise TypeError(
raise TypeError( # pragma: no cover
(
"DataLoader must be constructed with a function which accepts "
"Iterable<key> and returns Future<Iterable<value>>, but the function did "
Expand All @@ -248,7 +248,7 @@ async def dispatch_queue_batch(loader, queue):

values = list(values)
if len(values) != len(keys):
raise TypeError(
raise TypeError( # pragma: no cover
(
"DataLoader must be constructed with a function which accepts "
"Iterable<key> and returns Future<Iterable<value>>, but the function did "
Expand Down

0 comments on commit 1e7bfb7

Please sign in to comment.