Skip to content

Commit 1d0e550

Browse files
committed
Fix various warnings relating to Django upgrade from tox and testing.
1 parent 730e00c commit 1d0e550

File tree

7 files changed

+8
-15
lines changed

7 files changed

+8
-15
lines changed

django_nyt/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def login_required_ajax(f):
2828

2929
@wraps(f)
3030
def wrapper(request, *args, **kwargs):
31-
if request.is_ajax():
31+
if request.headers.get('x-requested-with') == 'XMLHttpRequest':
3232
if not request.user or not request.user.is_authenticated:
3333
return json_view(lambda *a,
3434
**kw: {'error': 'not logged in'})(request,

django_nyt/tests/test_management.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def test_notifymail(self):
4141
# It's normal for this command to exit
4242
pass
4343

44-
pid = open(pid_file.name, 'r').read()
44+
with open(pid_file.name, 'r') as fp:
45+
pid = fp.read()
4546
os.unlink(pid_file.name)
4647

4748
# Give it a second to start

django_nyt/urls.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from django.conf.urls import include
2-
from django.conf.urls import url
1+
from django.urls import include, re_path as url
32

43
from . import views
54

test-project/testapp/urls.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
try:
2-
from django.urls import include, re_path as url
3-
except ImportError:
4-
from django.conf.urls import include, url
1+
from django.urls import include, re_path as url
52

63
from . import views
74

test-project/testproject/settings/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
# django-nyt options
143143
##########################################
144144

145-
_enable_channels = True
145+
_enable_channels = False
146146
if _enable_channels:
147147
INSTALLED_APPS.append('channels')
148148
CHANNEL_LAYERS = {

test-project/testproject/urls.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
from django.conf import settings
33
from django.contrib import admin
44
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
5-
6-
try:
7-
from django.urls import include, re_path as url
8-
except ImportError:
9-
from django.conf.urls import include, url
5+
from django.urls import include, re_path as url
106

117

128
admin.autodiscover()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ whitelist_externals=
99
sh
1010

1111
commands =
12-
sh -c '! python test-project/manage.py makemigrations --dry-run --exit --noinput'
12+
sh -c '! python test-project/manage.py makemigrations --dry-run --noinput'
1313
python -W all:"":"":"":0 -m coverage run --source=django_nyt runtests.py
1414
codecov
1515

0 commit comments

Comments
 (0)