Chris McDonough
2012-02-28 e6d802ce67205464263e0eda224bdd723796d23b
hail mary windows
2 files modified
24 ■■■■■ changed files
pyramid/tests/test_config/test_assets.py 21 ●●●●● patch | view | raw | blame | history
pyramid/tests/test_integration.py 3 ●●●● patch | view | raw | blame | history
pyramid/tests/test_config/test_assets.py
@@ -163,9 +163,8 @@
        import pyramid.tests.test_config
        provider = self._makeOne(pyramid.tests.test_config)
        here = os.path.dirname(os.path.abspath(__file__))
        expected = read_(os.path.join(here, resource_name))
        with provider.get_resource_stream(None, resource_name) as result:
            self.assertEqual(result.read().replace(b'\r', b''), expected)
            _assertBody(result.read(), os.path.join(here, resource_name))
    def test_get_resource_string_no_overrides(self):
        import os
@@ -173,9 +172,8 @@
        import pyramid.tests.test_config
        provider = self._makeOne(pyramid.tests.test_config)
        here = os.path.dirname(os.path.abspath(__file__))
        expected = read_(os.path.join(here, resource_name))
        result = provider.get_resource_string(None, resource_name)
        self.assertEqual(result.replace(b'\r', b''), expected)
        _assertBody(result, os.path.join(here, resource_name))
    def test_has_resource_no_overrides(self):
        resource_name = 'test_assets.py'
@@ -221,9 +219,8 @@
        import pyramid.tests.test_config
        provider = self._makeOne(pyramid.tests.test_config)
        here = os.path.dirname(os.path.abspath(__file__))
        expected = read_(os.path.join(here, resource_name))
        with provider.get_resource_stream(None, resource_name) as result:
            self.assertEqual(result.read(), expected)
            _assertBody(result.read(), os.path.join(here, resource_name))
    def test_get_resource_string_override_returns_None(self):
        overrides = DummyOverrides(None)
@@ -420,10 +417,8 @@
        po = self._makeOne(package)
        po.overrides= overrides
        here = os.path.dirname(os.path.abspath(__file__))
        expected = read_(os.path.join(here, 'test_assets.py'))
        with po.get_stream('whatever') as stream:
            self.assertEqual(stream.read().replace(b'\r', b''),
                             expected)
            _assertBody(stream.read(), os.path.join(here, 'test_assets.py'))
        
    def test_get_stream_file_doesnt_exist(self):
        overrides = [ DummyOverride(None), DummyOverride(
@@ -595,3 +590,11 @@
        contents = f.read()
    return contents
def _assertBody(body, filename):
    # strip both \n and \r for windows
    body = body.replace(b'\\r', b'')
    body = body.replace(b'\\n', b'')
    data = read_(filename)
    data = data.replace(b'\\r', b'')
    data = data.replace(b'\\n', b'')
    assert(body == data)
pyramid/tests/test_integration.py
@@ -11,7 +11,6 @@
from pyramid.compat import (
    text_,
    url_quote,
    WIN,
    )
from zope.interface import Interface
@@ -623,5 +622,7 @@
    body = body.replace(b'\\r', b'')
    body = body.replace(b'\\n', b'')
    data = read_(filename)
    data = data.replace(b'\\r', b'')
    data = data.replace(b'\\n', b'')
    assert(body == data)