Skip to content

Commit

Permalink
test: Exclude parts of code from coverage calculation
Browse files Browse the repository at this point in the history
Exclude several sections of code from coverage calculation.  These
sections contain code that is repetitive or which is related to
debugging.
  • Loading branch information
riddell-stan committed Nov 30, 2020
1 parent 2d73ca0 commit 5417907
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions httpstan/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def _get_build_extension() -> distutils.command.build_ext.build_ext: # type: ignore
if HTTPSTAN_DEBUG:
if HTTPSTAN_DEBUG: # pragma: no cover
distutils.log.set_verbosity(distutils.log.DEBUG) # type: ignore
dist = distutils.core.Distribution()
# Make sure build respects distutils configuration
Expand Down Expand Up @@ -47,7 +47,7 @@ def _has_fileno(stream: TextIO) -> bool:
"""
try:
stream.fileno()
except (AttributeError, OSError, IOError, io.UnsupportedOperation):
except (AttributeError, OSError, IOError, io.UnsupportedOperation): # pragma: no cover
return False
return True

Expand Down
4 changes: 2 additions & 2 deletions httpstan/services_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# because `pickle` (used by ProcessPoolExecutor) cannot pickle local functions.
def _make_lazy_function_wrapper_helper(
function_basename: str, model_name: str, *args: typing.Any, **kwargs: typing.Any
) -> typing.Callable:
) -> typing.Callable: # pragma: no cover
services_module = httpstan.models.import_services_extension_module(model_name)
function = getattr(services_module, function_basename + "_wrapper")
return function(*args, **kwargs) # type: ignore
Expand Down Expand Up @@ -94,7 +94,7 @@ async def call(
lazy_function_wrapper_partial = functools.partial(lazy_function_wrapper, socket_filename, **kwargs)

# If HTTPSTAN_DEBUG is set block until sampling is complete. Do not use an executor.
if HTTPSTAN_DEBUG:
if HTTPSTAN_DEBUG: # pragma: no cover
future: asyncio.Future = asyncio.Future()
logger.debug("Calling stan::services function with debug mode on.")
print("Warning: httpstan debug mode is on! `num_samples` must be set to a small number (e.g., 10).")
Expand Down
12 changes: 6 additions & 6 deletions httpstan/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async def handle_delete_model(request: aiohttp.web.Request) -> aiohttp.web.Respo

try:
httpstan.models.import_services_extension_module(model_name)
except KeyError:
except KeyError: # pragma: no cover
message, status = f"Model `{model_name}` not found.", 404
return aiohttp.web.json_response(_make_error(message, status=status), status=status)

Expand Down Expand Up @@ -251,7 +251,7 @@ async def handle_show_params(request: aiohttp.web.Request) -> aiohttp.web.Respon

try:
services_module = httpstan.models.import_services_extension_module(model_name)
except KeyError:
except KeyError: # pragma: no cover
message, status = f"Model `{model_name}` not found.", 404
return aiohttp.web.json_response(_make_error(message, status=status), status=status)

Expand Down Expand Up @@ -342,7 +342,7 @@ async def handle_create_fit(request: aiohttp.web.Request) -> aiohttp.web.Respons

try:
httpstan.models.import_services_extension_module(model_name)
except KeyError:
except KeyError: # pragma: no cover
message, status = f"Model `{model_name}` not found.", 404
return aiohttp.web.json_response(_make_error(message, status=status), status=status)

Expand Down Expand Up @@ -453,7 +453,7 @@ async def handle_get_fit(request: aiohttp.web.Request) -> aiohttp.web.Response:

try:
fit_bytes_lz4 = httpstan.cache.load_fit(fit_name)
except KeyError:
except KeyError: # pragma: no cover
message, status = f"Fit `{fit_name}` not found.", 404
return aiohttp.web.json_response(_make_error(message, status=status), status=status)
fit_bytes = lz4.frame.decompress(fit_bytes_lz4)
Expand Down Expand Up @@ -495,7 +495,7 @@ async def handle_delete_fit(request: aiohttp.web.Request) -> aiohttp.web.Respons

try:
httpstan.cache.load_fit(fit_name)
except KeyError:
except KeyError: # pragma: no cover
message, status = f"Fit `{fit_name}` not found.", 404
return aiohttp.web.json_response(_make_error(message, status=status), status=status)

Expand Down Expand Up @@ -554,7 +554,7 @@ async def handle_get_operation(request: aiohttp.web.Request) -> aiohttp.web.Resp
operation_name = f"operations/{request.match_info['operation_id']}"
try:
operation = request.app["operations"][operation_name]
except KeyError:
except KeyError: # pragma: no cover
message, status = f"Operation `{operation_name}` not found.", 404
return aiohttp.web.json_response(_make_error(message, status=status), status=status)
return aiohttp.web.json_response(operation)

0 comments on commit 5417907

Please sign in to comment.