summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-02-28 00:53:15 -0500
committerChris McDonough <chrism@plope.com>2012-02-28 00:53:15 -0500
commit5dd2532447bea1f8f3816321d52937fc7ac9bda5 (patch)
tree419077ed36fdb6b41a7060fa207bd176f9ec76ba
parent8064bd5edb0ac8442aaf96946f85caf599dd213d (diff)
downloadpyramid-5dd2532447bea1f8f3816321d52937fc7ac9bda5.tar.gz
pyramid-5dd2532447bea1f8f3816321d52937fc7ac9bda5.tar.bz2
pyramid-5dd2532447bea1f8f3816321d52937fc7ac9bda5.zip
another hail mary to try to get things to work on windows+unix
-rw-r--r--pyramid/tests/test_integration.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py
index a9f0688ab..37be4701a 100644
--- a/pyramid/tests/test_integration.py
+++ b/pyramid/tests/test_integration.py
@@ -11,6 +11,7 @@ from pyramid.static import static_view
from pyramid.compat import (
text_,
url_quote,
+ WIN,
)
from zope.interface import Interface
@@ -240,9 +241,8 @@ class TestStaticPermApp(IntegrationBase, unittest.TestCase):
root_factory = 'pyramid.tests.pkgs.staticpermapp:RootFactory'
def test_allowed(self):
result = self.testapp.get('/allowed/index.html', status=200)
- self.assertEqual(
- result.body.replace(b'\r', b''),
- read_(os.path.join(here, 'fixtures/static/index.html')))
+ _assertBody(result.body,
+ os.path.join(here, 'fixtures/static/index.html'))
def test_denied_via_acl_global_root_factory(self):
self.testapp.extra_environ = {'REMOTE_USER':'bob'}
@@ -251,9 +251,8 @@ class TestStaticPermApp(IntegrationBase, unittest.TestCase):
def test_allowed_via_acl_global_root_factory(self):
self.testapp.extra_environ = {'REMOTE_USER':'fred'}
result = self.testapp.get('/protected/index.html', status=200)
- self.assertEqual(
- result.body.replace(b'\r', b''),
- read_(os.path.join(here, 'fixtures/static/index.html')))
+ _assertBody(result.body,
+ os.path.join(here, 'fixtures/static/index.html'))
def test_denied_via_acl_local_root_factory(self):
self.testapp.extra_environ = {'REMOTE_USER':'fred'}
@@ -262,9 +261,8 @@ class TestStaticPermApp(IntegrationBase, unittest.TestCase):
def test_allowed_via_acl_local_root_factory(self):
self.testapp.extra_environ = {'REMOTE_USER':'bob'}
result = self.testapp.get('/factory_protected/index.html', status=200)
- self.assertEqual(
- result.body.replace(b'\r', b''),
- read_(os.path.join(here, 'fixtures/static/index.html')))
+ _assertBody(result.body,
+ os.path.join(here, 'fixtures/static/index.html'))
class TestCCBug(IntegrationBase, unittest.TestCase):
# "unordered" as reported in IRC by author of
@@ -613,7 +611,7 @@ def httpdate(ts):
return ts.strftime("%a, %d %b %Y %H:%M:%S GMT")
def read_(filename):
- with open(filename, 'r') as fp:
+ with open(filename, 'rb') as fp:
val = fp.read()
return val
@@ -621,5 +619,9 @@ def _assertBody(body, filename):
if defaultlocale is None: # pragma: no cover
# If system locale does not have an encoding then default to utf-8
filename = filename.encode('utf-8')
- assert(body.replace(b'\r', b'') == read_(filename))
+ # strip both \n and \r for windows
+ body = body.replace(b'\\r', b'')
+ body = body.replace(b'\\n', b'')
+ data = read_(filename)
+ assert(body == data)