From 8064bd5edb0ac8442aaf96946f85caf599dd213d Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 28 Feb 2012 00:13:13 -0500 Subject: fix a few tests on windows, might fail on unix now, but i have to check in to find out --- pyramid/compat.py | 6 ++++++ pyramid/tests/test_integration.py | 2 +- pyramid/tests/test_url.py | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pyramid/compat.py b/pyramid/compat.py index 948a1c3be..51d7456f3 100644 --- a/pyramid/compat.py +++ b/pyramid/compat.py @@ -1,6 +1,12 @@ +import platform import sys import types +if platform.system() == 'Windows': + WIN = True +else: + WIN = False + try: # pragma: no cover import __pypy__ PYPY = True diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index 85a68ab25..a9f0688ab 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -613,7 +613,7 @@ def httpdate(ts): return ts.strftime("%a, %d %b %Y %H:%M:%S GMT") def read_(filename): - with open(filename, 'rb') as fp: + with open(filename, 'r') as fp: val = fp.read() return val diff --git a/pyramid/tests/test_url.py b/pyramid/tests/test_url.py index 7f002cbd6..d71bc7854 100644 --- a/pyramid/tests/test_url.py +++ b/pyramid/tests/test_url.py @@ -1,3 +1,4 @@ +import os import unittest import warnings @@ -8,6 +9,7 @@ from pyramid.testing import ( from pyramid.compat import ( text_, native_, + WIN, ) class TestURLMethodsMixin(unittest.TestCase): @@ -516,7 +518,7 @@ class TestURLMethodsMixin(unittest.TestCase): abspath = makeabs('static', 'foo.css') result = request.static_url(abspath) self.assertEqual(result, 'abc') - self.assertEqual(info.args, ('/static/foo.css', request, {})) + self.assertEqual(info.args, (makeabs('static', 'foo.css'), request, {})) request = self._makeOne() def test_static_url_found_rel(self): @@ -576,7 +578,7 @@ class TestURLMethodsMixin(unittest.TestCase): abspath = makeabs('static', 'foo.css') result = request.static_path(abspath) self.assertEqual(result, 'abc') - self.assertEqual(info.args, ('/static/foo.css', request, + self.assertEqual(info.args, (makeabs('static', 'foo.css'), request, {'_app_url':'/foo'}) ) @@ -986,5 +988,7 @@ class DummyStaticURLInfo: return self.result def makeabs(*elements): - import os - return os.path.sep + os.path.sep.join(elements) + if WIN: + return r'c:\\' + os.path.sep.join(elements) + else: + return os.path.sep + os.path.sep.join(elements) -- cgit v1.2.3