Skip to content

Commit

Permalink
test(static): attempt normalizing even more on M$ Windows...
Browse files Browse the repository at this point in the history
  • Loading branch information
vytas7 committed Aug 15, 2024
1 parent ea4675e commit 6eb97f6
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tests/test_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
import falcon.testing as testing


@pytest.fixture()
def client(asgi):
app = _util.create_app(asgi=asgi)
client = testing.TestClient(app)
client.asgi = asgi
return client


def normalize_path(path):
# NOTE(vytas): On CPython 3.13, ntpath.isabs() no longer returns True for
# Unix-like absolute paths that start with a single \.
Expand All @@ -35,6 +27,22 @@ def normalize_path(path):
return path


@pytest.fixture()
def client(asgi, monkeypatch):
def add_static_route_normalized(obj, prefix, directory, **kwargs):
add_static_route_orig(obj, prefix, normalize_path(directory), **kwargs)

app = _util.create_app(asgi=asgi)

app_cls = type(app)
add_static_route_orig = app_cls.add_static_route
monkeypatch.setattr(app_cls, 'add_static_route', add_static_route_normalized)

client = testing.TestClient(app)
client.asgi = asgi
return client


def create_sr(asgi, prefix, directory, **kwargs):
sr_type = StaticRouteAsync if asgi else StaticRoute
return sr_type(prefix, normalize_path(directory), **kwargs)
Expand Down

0 comments on commit 6eb97f6

Please sign in to comment.