Skip to content

Commit

Permalink
Increase code coverage (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz committed Feb 6, 2022
1 parent 9fde5e1 commit 6f008ea
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
10 changes: 1 addition & 9 deletions tests/django_urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
from __future__ import annotations

from django.http import HttpResponse
from django.urls import path


def hello_world(reqeust):
return HttpResponse(content="Hello Word", content_type="text/plain")


urlpatterns = [path("hello", hello_world)]
urlpatterns = []
6 changes: 2 additions & 4 deletions tests/test_compress.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import contextlib
import errno
import gzip
import os
import re
Expand All @@ -27,9 +26,8 @@ def files_dir():
path = os.path.join(tmp, path.lstrip("/"))
try:
os.makedirs(os.path.dirname(path))
except OSError as e:
if e.errno != errno.EEXIST:
raise
except FileExistsError:
pass
with open(path, "wb") as f:
f.write(contents)
timestamp = 1498579535
Expand Down
5 changes: 1 addition & 4 deletions tests/test_django_whitenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ def finder_static_files(request):
WHITENOISE_INDEX_FILE=True,
STATIC_ROOT=None,
):
try:
finders.get_finder.cache_clear()
except AttributeError:
finders._finders.clear()
finders.get_finder.cache_clear()
yield files


Expand Down
7 changes: 7 additions & 0 deletions tests/test_whitenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def server(application):
yield app_server


def test_invalid_kwarg():
with pytest.raises(TypeError) as excinfo:
WhiteNoise(None, invalid=True)

assert excinfo.value.args == ("Unexpected keyword argument 'invalid'",)


def assert_is_default_response(response):
assert "Hello world!" in response.text

Expand Down

0 comments on commit 6f008ea

Please sign in to comment.