From caf815921414d3766ec89e735f4d33559eb9d7a3 Mon Sep 17 00:00:00 2001 From: Allen Riddell Date: Mon, 30 Nov 2020 21:07:01 -0500 Subject: [PATCH] test: Adjust ignored code for coverage calculation Adjust ignored code for coverage calculation. Completes work started in commit 5417907391c487ba910708f4af441f2209f3dfb8. --- .github/workflows/main.yml | 2 +- httpstan/models.py | 2 +- httpstan/schemas.py | 4 ++-- httpstan/views.py | 2 +- pyproject.toml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9a5db747f..ef87c1ff8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: python -m pip install dist/*.whl - name: Run tests - run: "python -m pytest -s -v --cov=httpstan tests" + run: python -m pytest -s -v --cov=httpstan tests - name: Test PyStan compatibility run: | diff --git a/httpstan/models.py b/httpstan/models.py index 1f937e9b0..f0206b040 100644 --- a/httpstan/models.py +++ b/httpstan/models.py @@ -151,7 +151,7 @@ async def build_services_extension_module(program_code: str, extra_compile_args: # where to find shared libraries during execution. There are two ways for an # extension module to find shared libraries: LD_LIBRARY_PATH and rpath. libraries = ["sundials_cvodes", "sundials_idas", "sundials_nvecserial", "tbb"] - if platform.system() == "Darwin": + if platform.system() == "Darwin": # pragma: no cover libraries.extend(["tbbmalloc", "tbbmalloc_proxy"]) extension = setuptools.Extension( f"stan_services_{stan_model_name}", # filename only. Module name is "stan_services" diff --git a/httpstan/schemas.py b/httpstan/schemas.py index e9f774ad2..80359268c 100644 --- a/httpstan/schemas.py +++ b/httpstan/schemas.py @@ -23,9 +23,9 @@ class Operation(marshmallow.Schema): @marshmallow.validates_schema def validate_result(self, data: dict, many: bool, partial: bool) -> None: assert not many and not partial, "Use of `many` and `partial` with schema unsupported." - if data["done"] and data.get("result") is None: + if data["done"] and data.get("result") is None: # pragma: no cover raise marshmallow.ValidationError("If `done` then `result` must be set.", "result") - if not data["done"] and data.get("result"): + if not data["done"] and data.get("result"): # pragma: no cover raise marshmallow.ValidationError("If not `done` then `result` must be empty.", "result") diff --git a/httpstan/views.py b/httpstan/views.py index e69e3e20c..d2fae0359 100644 --- a/httpstan/views.py +++ b/httpstan/views.py @@ -112,7 +112,7 @@ async def handle_create_model(request: aiohttp.web.Request) -> aiohttp.web.Respo try: # `build_services_extension_module` has side-effect of storing extension module in cache compiler_output = await httpstan.models.build_services_extension_module(program_code) - except Exception as exc: + except Exception as exc: # pragma: no cover message, status = ( f"Exception while building model extension module: `{repr(exc)}`, traceback: `{traceback.format_tb(exc.__traceback__)}`", 400, diff --git a/pyproject.toml b/pyproject.toml index aff795629..a4f6260ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ known_local_folder = "helpers" [tool.coverage.run] branch = true -omit = httpstan/__main__.py +omit = ["httpstan/__main__.py"] [tool.coverage.report] fail_under = 95