From cec6b96d8b8ae662028d7f0901cacceeb2eb1c97 Mon Sep 17 00:00:00 2001 From: MF2199 <38331387+mf2199@users.noreply.github.com> Date: Mon, 31 Aug 2020 16:40:42 -0400 Subject: [PATCH] feat: Stage 5 of `nox` implementation - adding coverage targets (#479) --- .coveragerc | 23 +++++++++++++++++++++++ noxfile.py | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000000..b1a1aa9cf5 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Google LLC +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +[run] +branch = True + +[report] +fail_under = 100 +show_missing = True +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore abstract methods + raise NotImplementedError +omit = + */site-packages/*.py \ No newline at end of file diff --git a/noxfile.py b/noxfile.py index 4570168cd3..016fe33c39 100644 --- a/noxfile.py +++ b/noxfile.py @@ -69,6 +69,13 @@ def default(session): session.run( "py.test", "--quiet", + "--cov=django_spanner", + "--cov=spanner_dbapi", + "--cov=tests.spanner_dbapi", + "--cov-append", + "--cov-config=.coveragerc", + "--cov-report=", + "--cov-fail-under=0", os.path.join("tests", "spanner_dbapi"), *session.posargs ) @@ -80,6 +87,18 @@ def unit(session): default(session) +@nox.session(python="3.8") +def cover(session): + """Run the final coverage report. + + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=20") + session.run("coverage", "erase") + + @nox.session(python="3.8") def docs(session): """Build the docs for this library."""