Skip to content

Commit

Permalink
Fix: coverage output would prefix _covered_ lines with "#"; should be…
Browse files Browse the repository at this point in the history
…_uncovered_ lines
  • Loading branch information
andreas-zeller committed Dec 6, 2023
1 parent 0edac9b commit 8bf6898
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 9 additions & 7 deletions notebooks/Coverage.ipynb
Expand Up @@ -925,7 +925,8 @@
}
},
"source": [
"Let us print out the full code, annotating lines not covered with '#':"
"Let us print out the full code, annotating lines not covered with `#`.\n",
"The idea of such an annotation is to direct developer's attention to the non-covered lines."
]
},
{
Expand Down Expand Up @@ -966,7 +967,8 @@
}
},
"source": [
"We see that a number of lines (notably comments) have not been executed, simply because they are not executable. However, we also see that the lines under `if c == '%'` have _not_ been executed yet. If `\"a+b\"` were our only test case so far, this missing coverage would now encourage us to create another test case that actually covers these lines."
"We see that a number of lines (notably comments) have not been executed (marked with `#`), simply because they are not executable.\n",
"However, we also see that the lines under `if c == '%'` have _not_ been executed yet. If `\"a+b\"` were our only test case so far, this missing coverage would now encourage us to create another test case that actually covers these lines."
]
},
{
Expand Down Expand Up @@ -1092,7 +1094,7 @@
" sys.settrace(self.traceit)\n",
" return self\n",
"\n",
" def __exit__(self, exc_type: Type, exc_value: BaseException, \n",
" def __exit__(self, exc_type: Type, exc_value: BaseException,\n",
" tb: TracebackType) -> Optional[bool]:\n",
" \"\"\"End of `with` block. Turn off tracing.\"\"\"\n",
" sys.settrace(self.original_trace_function)\n",
Expand Down Expand Up @@ -1124,7 +1126,7 @@
"\n",
" source_lines, start_line_number = inspect.getsourcelines(fun)\n",
" for lineno in range(start_line_number, start_line_number + len(source_lines)):\n",
" if (function_name, lineno) in self.trace():\n",
" if (function_name, lineno) not in self.trace():\n",
" t += \"# \"\n",
" else:\n",
" t += \" \"\n",
Expand Down Expand Up @@ -1191,7 +1193,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For interactive use, we can simply print the coverage object, and obtain a listing of the code, with covered lines marked as `#`."
"For interactive use, we can simply print the coverage object, and obtain a listing of the code, again with non-covered lines marked as `#`."
]
},
{
Expand Down Expand Up @@ -2363,7 +2365,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Printing out a coverage object shows the covered functions, with covered lines prefixed as `#`:"
"Printing out a coverage object shows the covered functions, with non-covered lines prefixed as `#`:"
]
},
{
Expand Down Expand Up @@ -3429,7 +3431,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.12.0"
},
"toc": {
"base_numbering": 1,
Expand Down
4 changes: 3 additions & 1 deletion notebooks/ReleaseNotes.ipynb
Expand Up @@ -28,7 +28,9 @@
"## Current Version (in progress)\n",
"\n",
"This is the version we are preparing for the next release (e.g. what you get when you check out the latest version from [the GitHub repo](__GITHUB_HTML__)).\n",
"Major changes will show up here as we make them."
"Major changes will show up here as we make them.\n",
"\n",
"* Fix: Outputting code coverage using `Coverage` class would prefix _covered_ code with `#`, rather than _uncovered_ code as should be. This has been fixed."
]
},
{
Expand Down

0 comments on commit 8bf6898

Please sign in to comment.