Skip to content

Commit 74e5ee2

Browse files
author
jjjkkkjjj
committed
removed reverse function (#2110)
1 parent 29c7402 commit 74e5ee2

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

channels/routing.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from django.core.exceptions import ImproperlyConfigured
66
from django.urls.exceptions import Resolver404
77
from django.urls.resolvers import RegexPattern, RoutePattern, URLResolver, URLPattern
8-
from django.urls import reverse as django_reverse
98

109
"""
1110
All Routing instances inside this file are also valid ASGI applications - with
@@ -234,25 +233,3 @@ async def __call__(self, scope, receive, send):
234233
raise ValueError(
235234
"No application configured for channel name %r" % scope["channel"]
236235
)
237-
238-
239-
def reverse(*args, urlconf=None, **kwargs):
240-
"""reverse wrapper for django's reverse function
241-
242-
Parameters
243-
----------
244-
urlconf : str, optional
245-
The root path of the routings, by default None
246-
247-
See the django's
248-
[reverse](https://docs.djangoproject.com/en/5.0/ref/urlresolvers/#reverse)
249-
for more details of the other arguments
250-
251-
Returns
252-
-------
253-
str
254-
The reversed url
255-
"""
256-
if urlconf is None:
257-
urlconf = settings.ROOT_WEBSOCKET_URLCONF
258-
return django_reverse(*args, urlconf=urlconf, **kwargs)

tests/test_routing.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from django.urls import path, re_path
33

4-
from channels.routing import ChannelNameRouter, ProtocolTypeRouter, URLRouter, reverse
4+
from channels.routing import ChannelNameRouter, ProtocolTypeRouter, URLRouter
55

66

77
class MockApplication:
@@ -377,7 +377,6 @@ async def test_url_router_nesting_by_include(root_urlconf):
377377
== 1
378378
)
379379
assert django_reverse("moon", urlconf=root_urlconf) == "/moon/"
380-
assert reverse("moon") == "/moon/"
381380

382381
assert (
383382
await outer_router(
@@ -391,7 +390,6 @@ async def test_url_router_nesting_by_include(root_urlconf):
391390
== 1
392391
)
393392
assert django_reverse("mars", urlconf=root_urlconf, args=(5,)) == "/mars/5/"
394-
assert reverse("mars", args=(5,)) == "/mars/5/"
395393

396394
assert (
397395
await outer_router(
@@ -412,10 +410,6 @@ async def test_url_router_nesting_by_include(root_urlconf):
412410
)
413411
== "/universe/book/channels-guide/page/10/"
414412
)
415-
assert (
416-
reverse("universe:book", kwargs=dict(book="channels-guide", page=10))
417-
== "/universe/book/channels-guide/page/10/"
418-
)
419413

420414
assert (
421415
await outer_router(
@@ -432,7 +426,6 @@ async def test_url_router_nesting_by_include(root_urlconf):
432426
django_reverse("universe:test", urlconf=root_urlconf, args=(10,))
433427
== "/universe/test/10/"
434428
)
435-
assert reverse("universe:test", args=(10,)) == "/universe/test/10/"
436429

437430
assert (
438431
await outer_router(
@@ -446,7 +439,6 @@ async def test_url_router_nesting_by_include(root_urlconf):
446439
== 1
447440
)
448441
assert django_reverse("universe:home", urlconf=root_urlconf) == "/universe/home/"
449-
assert reverse("universe:home") == "/universe/home/"
450442

451443

452444
@pytest.mark.asyncio
@@ -543,7 +535,6 @@ async def test_url_router_deep_nesting_by_include(root_urlconf):
543535
== 1
544536
)
545537
assert django_reverse("moon", urlconf=root_urlconf) == "/moon/"
546-
assert reverse("moon") == "/moon/"
547538

548539
assert (
549540
await outer_router(
@@ -557,7 +548,6 @@ async def test_url_router_deep_nesting_by_include(root_urlconf):
557548
== 1
558549
)
559550
assert django_reverse("mars", urlconf=root_urlconf, args=(5,)) == "/mars/5/"
560-
assert reverse("mars", args=(5,)) == "/mars/5/"
561551

562552
assert (
563553
await outer_router(
@@ -578,10 +568,6 @@ async def test_url_router_deep_nesting_by_include(root_urlconf):
578568
)
579569
== "/universe/earth/book/channels-guide/page/10/"
580570
)
581-
assert (
582-
reverse("universe:earth:book", kwargs=dict(book="channels-guide", page=10))
583-
== "/universe/earth/book/channels-guide/page/10/"
584-
)
585571

586572
assert (
587573
await outer_router(
@@ -598,7 +584,6 @@ async def test_url_router_deep_nesting_by_include(root_urlconf):
598584
django_reverse("universe:earth:test", urlconf=root_urlconf, args=(10,))
599585
== "/universe/earth/test/10/"
600586
)
601-
assert reverse("universe:earth:test", args=(10,)) == "/universe/earth/test/10/"
602587

603588
assert (
604589
await outer_router(
@@ -615,4 +600,3 @@ async def test_url_router_deep_nesting_by_include(root_urlconf):
615600
django_reverse("universe:earth:home", urlconf=root_urlconf)
616601
== "/universe/earth/home/"
617602
)
618-
assert reverse("universe:earth:home") == "/universe/earth/home/"

0 commit comments

Comments
 (0)