Skip to content

Commit

Permalink
use unicode path names to make tests pass on jython (also happens to …
Browse files Browse the repository at this point in the history
…be the right thing, thanks jython)
  • Loading branch information
mcdonc committed Sep 8, 2011
1 parent 05b8a60 commit c55903c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
5 changes: 4 additions & 1 deletion pyramid/static.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os
from os.path import normcase, normpath, join, getmtime, getsize, isdir, exists
from pkg_resources import resource_exists, resource_filename, resource_isdir
Expand Down Expand Up @@ -178,4 +179,6 @@ def _secure_path(path_tuple):
return None
if any([contains_slash(item) for item in path_tuple]):
return None
return '/'.join([x.encode('utf-8') for x in path_tuple])
encoded = u'/'.join(path_tuple) # will be unicode
return encoded

24 changes: 14 additions & 10 deletions pyramid/tests/test_integration.py
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import os
import unittest

Expand Down Expand Up @@ -72,20 +74,22 @@ def test_basic(self):

def test_hidden(self):
res = self.testapp.get('/static/.hiddenfile', status=200)
self._assertBody(res.body, os.path.join(here,
'fixtures/static/.hiddenfile'))
self._assertBody(
res.body,
os.path.join(here, 'fixtures/static/.hiddenfile')
)

def test_highchars_in_pathelement(self):
res = self.testapp.get('/static/h\xc3\xa9h\xc3\xa9/index.html',
status=200)
self._assertBody(res.body, os.path.join(
here, 'fixtures/static/h\xc3\xa9h\xc3\xa9/index.html'))
res = self.testapp.get('/static/héhé/index.html', status=200)
self._assertBody(
res.body, os.path.join(here, u'fixtures/static/héhé/index.html')
)

def test_highchars_in_filename(self):
res = self.testapp.get('/static/h\xc3\xa9h\xc3\xa9.html',
status=200)
self._assertBody(res.body, os.path.join(
here, 'fixtures/static/h\xc3\xa9h\xc3\xa9.html'))
res = self.testapp.get('/static/héhé.html', status=200)
self._assertBody(
res.body, os.path.join(here, u'fixtures/static/héhé.html')
)

def test_not_modified(self):
self.testapp.extra_environ = {
Expand Down

0 comments on commit c55903c

Please sign in to comment.