Skip to content

Commit

Permalink
Explicitly mark missing testing coverage and require 100% now
Browse files Browse the repository at this point in the history
This helps identifying current coverage gaps and avoid adding new ones
while adding new code.
  • Loading branch information
marcospri committed Jan 25, 2024
1 parent 9bfd184 commit 8c1f5e9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ source =
[report]
show_missing = True
precision = 2
fail_under = 96.63
fail_under = 100
4 changes: 2 additions & 2 deletions bouncer/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def git_version():
return pep440_version(date, ref, dirty)


def git_archive_version():
def git_archive_version(): # pragma: nocover
ref = VERSION_GIT_REF
date = datetime.datetime.fromtimestamp(int(VERSION_GIT_DATE))
return pep440_version(date, ref)
Expand All @@ -56,7 +56,7 @@ def pep440_version(date, ref, dirty=False):
)


def get_version():
def get_version(): # pragma: nocover
"""Fetch the current application version."""
# First we try to retrieve the current application version from git.
try:
Expand Down
9 changes: 3 additions & 6 deletions bouncer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pyramid.config


def settings():
def settings(): # pragma: nocover
"""
Return the app's configuration settings as a dict.
Expand All @@ -16,10 +16,7 @@ def settings():
if via_base_url.endswith("/"):
via_base_url = via_base_url[:-1]

if "DEBUG" in os.environ:
debug = True
else:
debug = False
debug = "DEBUG" in os.environ

extension_ids = os.environ.get(
"CHROME_EXTENSION_ID", "bjfhmglciegochdpefhhlphglcehbmek"
Expand All @@ -45,7 +42,7 @@ def settings():
return result


def create_app(_=None, **_settings):
def create_app(_=None, **_settings): # pragma: nocover
"""Configure and return the WSGI app."""
config = pyramid.config.Configurator(settings=settings())
config.add_static_view(name="static", path="static")
Expand Down
2 changes: 1 addition & 1 deletion bouncer/embed_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
COMPILED_PATTERNS = [re.compile(fnmatch.translate(pat)) for pat in PATTERNS]


def url_embeds_client(url):
def url_embeds_client(url): # pragma: nocover
"""
Test whether ``url`` is known to embed the client.
Expand Down
2 changes: 1 addition & 1 deletion bouncer/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_client(settings):
return Elasticsearch([host], **kwargs)


def includeme(config):
def includeme(config): # pragma: nocover
settings = config.registry.settings
settings.setdefault("elasticsearch_url", "http://localhost:9200")

Expand Down
8 changes: 4 additions & 4 deletions bouncer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def parse_document(document):

try:
targets = annotation["target"]
if targets:
if targets: # pragma: nocover
document_uri = targets[0]["source"]
selectors = targets[0].get("selector", [])
for selector in selectors:
Expand All @@ -113,9 +113,9 @@ def parse_document(document):
if isinstance(document_uri, str) and document_uri.startswith("urn:x-pdf:"):
try:
web_uri = annotation["document"]["web_uri"]
if web_uri:
if web_uri: # pragma: nocover
document_uri = web_uri
except KeyError:
except KeyError: # pragma: nocover
pass

if document_uri is None:
Expand Down Expand Up @@ -148,7 +148,7 @@ def get_pretty_url(url):
return None

pretty_url = parsed_url.netloc[:NETLOC_MAX_LENGTH]
if len(parsed_url.netloc) > NETLOC_MAX_LENGTH:
if len(parsed_url.netloc) > NETLOC_MAX_LENGTH: # pragma: nocover
pretty_url += jinja2.Markup("…")
return pretty_url

Expand Down
2 changes: 1 addition & 1 deletion bouncer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def annotation(self):


@view.view_config(renderer="bouncer:templates/index.html.jinja2", route_name="index")
def index(request):
def index(request): # pragma: nocover
raise httpexceptions.HTTPFound(location=request.registry.settings["hypothesis_url"])


Expand Down

0 comments on commit 8c1f5e9

Please sign in to comment.