Skip to content

Instantly share code, notes, and snippets.

@BigBlueHat
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigBlueHat/11144543 to your computer and use it in GitHub Desktop.
Save BigBlueHat/11144543 to your computer and use it in GitHub Desktop.
aspen.io test failures on Windows
Ignoring indexes: https://pypi.python.org/simple/
Requirement already satisfied (use --upgrade to upgrade): coverage>=3.7.1 in c:\users\benjamin\documents\github\aspen-python\env\lib\site-packages
Cleaning up...
env\Scripts\pip.exe install --no-index --find-links=./vendor/test coverage>=3.7.1
Ignoring indexes: https://pypi.python.org/simple/
Requirement already satisfied (use --upgrade to upgrade): cov-core>=1.7 in c:\users\benjamin\documents\github\aspen-python\env\lib\site-packages
Cleaning up...
env\Scripts\pip.exe install --no-index --find-links=./vendor/test cov-core>=1.7
Ignoring indexes: https://pypi.python.org/simple/
Requirement already satisfied (use --upgrade to upgrade): py>=1.4.20 in c:\users\benjamin\documents\github\aspen-python\env\lib\site-packages
Cleaning up...
env\Scripts\pip.exe install --no-index --find-links=./vendor/test py>=1.4.20
Ignoring indexes: https://pypi.python.org/simple/
Requirement already satisfied (use --upgrade to upgrade): pytest>=2.5.2 in c:\users\benjamin\documents\github\aspen-python\env\lib\site-packages
Cleaning up...
env\Scripts\pip.exe install --no-index --find-links=./vendor/test pytest>=2.5.2
Ignoring indexes: https://pypi.python.org/simple/
Requirement already satisfied (use --upgrade to upgrade): pytest-cov>=1.6 in c:\users\benjamin\documents\github\aspen-python\env\lib\site-packages
Cleaning up...
env\Scripts\pip.exe install --no-index --find-links=./vendor/test pytest-cov>=1.6
============================= test session starts =============================
platform win32 -- Python 2.7.6 -- py-1.4.20 -- pytest-2.5.2
plugins: cov
collected 527 items / 1 skipped
tests/test_charset_re.py .............
tests/test_configuration.py ........ss.........................x........
tests/test_dispatcher.py ..F.F........................................................................
tests/test_execution.py .
tests/test_httpbasic.py ......
tests/test_httpdigest.py ....
tests/test_json_resource.py .................
tests/test_logging.py ....
tests/test_mappings.py ......................
tests/test_negotiated_resource.py ..................................
tests/test_request.py ...........................
tests/test_request_body.py .......
tests/test_request_line.py .......................................................................................................................................
tests/test_resources.py ....................
tests/test_resources_generics.py .......................
tests/test_response.py .......
tests/test_sockets_.py ...
tests/test_sockets_buffer.py ...
tests/test_sockets_channel.py .....
tests/test_sockets_message.py ..................
tests/test_sockets_packet.py .....
tests/test_sockets_socket.py .....
tests/test_sockets_transport.py .......F.
tests/test_utils.py .......F.F
tests/test_website.py .............FFFF..FF...F
tests/test_website_flow.py .F
tests/test_weird.py .
================================== FAILURES ===================================
______________________ test_alternate_index_is_not_found ______________________
harness = <aspen.testing.harness.Harness object at 0x0000000003453EF0>
def test_alternate_index_is_not_found(harness):
> assert_raises_404(harness, '/')
..\..\..\..\Documents\GitHub\aspen-python\tests\test_dispatcher.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<aspen.testing.harness.Harness object at 0x0000000003453EF0>, '/', '')
def assert_raises_404(*args):
if len(args) < 3: args += ('',)
> response = raises(Response, assert_fs, *args).value
..\..\..\..\Documents\GitHub\aspen-python\tests\test_dispatcher.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
harness = <aspen.testing.harness.Harness object at 0x0000000003453EF0>
ask_uri = '/', expect_fs = ''
def assert_fs(harness, ask_uri, expect_fs):
> actual = harness.simple(uripath=ask_uri, filepath=None, want='request.fs')
..\..\..\..\Documents\GitHub\aspen-python\tests\test_dispatcher.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.testing.harness.Harness object at 0x0000000003453EF0>
contents = 'Greetings, program!', filepath = None, uripath = '/', argv = None
kw = {'want': 'request.fs'}
def simple(self, contents='Greetings, program!', filepath='index.html.spt', uripath=None,
argv=None, **kw):
"""A helper to create a file and hit it through our machinery.
"""
if filepath is not None:
self.fs.www.mk((filepath, contents))
if argv is not None:
self.client.hydrate_website(argv)
if uripath is None:
if filepath is None:
uripath = '/'
else:
uripath = '/' + filepath
if uripath.endswith('.spt'):
uripath = uripath[:-len('.spt')]
for indexname in self.client.website.indices:
if uripath.endswith(indexname):
uripath = uripath[:-len(indexname)]
break
> return self.client.GET(uripath, **kw)
..\..\..\..\documents\github\aspen-python\aspen\testing\harness.py:88:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.testing.client.Client object at 0x0000000003910128>, a = ('/',)
kw = {'want': 'request.fs'}
> def GET(self, *a, **kw): return self.hit('GET', *a, **kw)
..\..\..\..\documents\github\aspen-python\aspen\testing\client.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.testing.client.Client object at 0x0000000003910128>
method = 'GET', path = '/', data = {}, body = '--BoUnDaRyStRiNg--\r\n'
content_type = 'multipart/form-data; boundary=BoUnDaRyStRiNg'
raise_immediately = True, return_after = None, want = 'request.fs', headers = {}
environ = {'CONTENT_TYPE': 'multipart/form-data; boundary=BoUnDaRyStRiNg', 'HTTP_COOKIE': '', 'HTTP_HOST': 'localhost', 'PATH_INFO': '/', ...}
def hit(self, method, path='/', data=None, body=b'', content_type=MULTIPART_CONTENT,
raise_immediately=True, return_after=None, want='response', **headers):
data = {} if data is None else data
if content_type is MULTIPART_CONTENT:
body = encode_multipart(BOUNDARY, data)
environ = self.build_wsgi_environ(method, path, body, str(content_type), **headers)
state = self.website.respond( environ
, raise_immediately=raise_immediately
> , return_after=return_after
)
..\..\..\..\documents\github\aspen-python\aspen\testing\client.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.website.Website object at 0x00000000039102E8>
environ = {'CONTENT_TYPE': 'multipart/form-data; boundary=BoUnDaRyStRiNg', 'HTTP_COOKIE': '', 'HTTP_HOST': 'localhost', 'PATH_INFO': '/', ...}
raise_immediately = True, return_after = None
def respond(self, environ, raise_immediately=None, return_after=None):
"""Given a WSGI environ, return a state dict.
"""
return self.algorithm.run( website=self
, environ=environ
, _raise_immediately=raise_immediately
> , _return_after=return_after
)
..\..\..\..\documents\github\aspen-python\aspen\website.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <algorithm.Algorithm object at 0x0000000003910390>
_raise_immediately = True, _return_after = None
state = {'algorithm': <algorithm.Algorithm object at 0x0000000003910390>, 'environ': {'CONTENT_TYPE': 'multipart/form-data; bo... / HTTP/1.1\r\nContent-Type: multipart/form-data; boundary=BoUnDaRyStRiNg\r\nHost: localhost\r\nCookie: \r\n\r\n', ...}
function = <function get_resource_for_request at 0x00000000033A7CF8>
function_name = 'get_resource_for_request'
deps = Dependencies(as_args=('GET / HTTP/1.1\r\nContent-Type: multipart/form-data; bo...meters=('request', 'response'), required=('request', 'response'), optional={}))
have_exception = False, new_state = {'response': None}
ExceptionClass = <class 'aspen.exceptions.LoadError'>
exception = LoadError('Traceback (most recent call last):\n File "c:\\users\\benjamin\\do...rs\\\\benjamin\\\\appdata\\\\local\\\\temp\\\\filesystem-tree-lfzfvd\\\\\'\n',)
def run(self, _raise_immediately=None, _return_after=None, **state):
"""Run through the functions in the :py:attr:`functions` list.
:param bool _raise_immediately: if not ``None``, will override any
default for ``raise_immediately`` that was set in the constructor
:param str _return_after: if not ``None``, return after calling the function
with this name
:param dict state: remaining keyword arguments are used for the initial
state dictionary for this run of the algorithm
:raises: :py:exc:`FunctionNotFound`, if there is no function named
``_return_after``
:returns: a dictionary representing the final algorithm state
The state dictionary is initialized with three items (their default
values can be overriden using keyword arguments to :py:func:`run`):
- ``algorithm`` - a reference to the parent :py:class:`Algorithm` instance
- ``state`` - a circular reference to the state dictionary
- ``exception`` - ``None``
For each function in the :py:attr:`functions` list, we look at the
function signature and compare it to the current value of ``exception``
in the state dictionary. If ``exception`` is ``None`` then we skip any
function that asks for ``exception``, and if ``exception`` is *not*
``None`` then we only call functions that *do* ask for it. The upshot
is that any function that raises an exception will cause us to
fast-forward to the next exception-handling function in the list.
Here are some further notes on exception handling:
- If a function provides a default value for ``exception``, then that
function will be called whether or not there is an exception being
handled.
- You should return ``{'exception': None}`` to reset exception
handling. Under Python 2 we will call ``sys.exc_clear`` for you
(under Python 3 exceptions are cleared automatically at the end of
except blocks).
- If ``exception`` is not ``None`` after all functions have been run,
then we re-raise it.
- If ``raise_immediately`` evaluates to ``True`` (looking first at any
per-call ``_raise_immediately`` and then at the instance default),
then we re-raise any exception immediately instead of
fast-forwarding to the next exception handler.
"""
if _raise_immediately is None:
_raise_immediately = self.default_raise_immediately
if _return_after is not None:
if _return_after not in self.get_names():
raise FunctionNotFound(_return_after)
if 'algorithm' not in state: state['algorithm'] = self
if 'state' not in state: state['state'] = state
if 'exception' not in state: state['exception'] = None
for function in self.functions:
function_name = function.__name__
try:
deps = resolve_dependencies(function, state)
have_exception = state['exception'] is not None
if 'exception' in deps.signature.required and not have_exception:
pass # Function wants exception but we don't have it.
elif 'exception' not in deps.signature.parameters and have_exception:
pass # Function doesn't want exception but we have it.
else:
> new_state = function(**deps.as_kwargs)
..\..\..\..\Documents\GitHub\aspen-python\env\lib\site-packages\algorithm.py:288:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = 'GET / HTTP/1.1\r\nContent-Type: multipart/form-data; boundary=BoUnDaRyStRiNg\r\nHost: localhost\r\nCookie: \r\n\r\n'
response = None
def get_resource_for_request(request, response):
if response is None:
> return {'resource': resources.get(request)}
..\..\..\..\documents\github\aspen-python\aspen\algorithms\website.py:87:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = 'GET / HTTP/1.1\r\nContent-Type: multipart/form-data; boundary=BoUnDaRyStRiNg\r\nHost: localhost\r\nCookie: \r\n\r\n'
def get(request):
"""Given a Request, return a Resource object (with caching).
We need the request because it carries media_type_default.
"""
# XXX This is not thread-safe. It used to be, but then I simplified it
# when I switched to diesel. Now that we have multiple engines, some of
# which are threaded, we need to make this thread-safe again.
# Get a cache Entry object.
# =========================
if request.fs not in __cache__:
entry = Entry()
__cache__[request.fs] = entry
entry = __cache__[request.fs]
# Process the resource.
# =====================
mtime = os.stat(request.fs)[stat.ST_MTIME]
if entry.mtime == mtime: # cache hit
if entry.exc is not None:
raise entry.exc
else: # cache miss
try:
entry.resource = load(request, mtime)
except: # capture any Exception
entry.exc = (LoadError(traceback.format_exc())
, sys.exc_info()[2]
)
else: # reset any previous Exception
entry.exc = None
entry.mtime = mtime
if entry.exc is not None:
> raise entry.exc[0] # TODO Why [0] here, and not above?
E LoadError: Traceback (most recent call last):
E File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 142, in get
E entry.resource = load(request, mtime)
E File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 78, in load
E raw_fh = open(request.fs, 'rb')
E IOError: [Errno 2] No such file or directory: u'c:\\users\\benjamin\\appdata\\local\\temp\\filesystem-tree-lfzfvd\\'
..\..\..\..\documents\github\aspen-python\aspen\resources\__init__.py:152: LoadError
_____________ test_configure_aspen_py_setting_override_works_too ______________
harness = <aspen.testing.harness.Harness object at 0x000000000330A5C0>
def test_configure_aspen_py_setting_override_works_too(harness):
harness.fs.project.mk(('configure-aspen.py', 'website.indices = ["default.html"]'),)
harness.fs.www.mk(('index.html', "Greetings, program!"),)
> assert_raises_404(harness, '/')
..\..\..\..\Documents\GitHub\aspen-python\tests\test_dispatcher.py:72:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<aspen.testing.harness.Harness object at 0x000000000330A5C0>, '/', '')
def assert_raises_404(*args):
if len(args) < 3: args += ('',)
> response = raises(Response, assert_fs, *args).value
..\..\..\..\Documents\GitHub\aspen-python\tests\test_dispatcher.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
harness = <aspen.testing.harness.Harness object at 0x000000000330A5C0>
ask_uri = '/', expect_fs = ''
def assert_fs(harness, ask_uri, expect_fs):
> actual = harness.simple(uripath=ask_uri, filepath=None, want='request.fs')
..\..\..\..\Documents\GitHub\aspen-python\tests\test_dispatcher.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.testing.harness.Harness object at 0x000000000330A5C0>
contents = 'Greetings, program!', filepath = None, uripath = '/', argv = None
kw = {'want': 'request.fs'}
def simple(self, contents='Greetings, program!', filepath='index.html.spt', uripath=None,
argv=None, **kw):
"""A helper to create a file and hit it through our machinery.
"""
if filepath is not None:
self.fs.www.mk((filepath, contents))
if argv is not None:
self.client.hydrate_website(argv)
if uripath is None:
if filepath is None:
uripath = '/'
else:
uripath = '/' + filepath
if uripath.endswith('.spt'):
uripath = uripath[:-len('.spt')]
for indexname in self.client.website.indices:
if uripath.endswith(indexname):
uripath = uripath[:-len(indexname)]
break
> return self.client.GET(uripath, **kw)
..\..\..\..\documents\github\aspen-python\aspen\testing\harness.py:88:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.testing.client.Client object at 0x00000000033A3198>, a = ('/',)
kw = {'want': 'request.fs'}
> def GET(self, *a, **kw): return self.hit('GET', *a, **kw)
..\..\..\..\documents\github\aspen-python\aspen\testing\client.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.testing.client.Client object at 0x00000000033A3198>
method = 'GET', path = '/', data = {}, body = '--BoUnDaRyStRiNg--\r\n'
content_type = 'multipart/form-data; boundary=BoUnDaRyStRiNg'
raise_immediately = True, return_after = None, want = 'request.fs', headers = {}
environ = {'CONTENT_TYPE': 'multipart/form-data; boundary=BoUnDaRyStRiNg', 'HTTP_COOKIE': '', 'HTTP_HOST': 'localhost', 'PATH_INFO': '/', ...}
def hit(self, method, path='/', data=None, body=b'', content_type=MULTIPART_CONTENT,
raise_immediately=True, return_after=None, want='response', **headers):
data = {} if data is None else data
if content_type is MULTIPART_CONTENT:
body = encode_multipart(BOUNDARY, data)
environ = self.build_wsgi_environ(method, path, body, str(content_type), **headers)
state = self.website.respond( environ
, raise_immediately=raise_immediately
> , return_after=return_after
)
..\..\..\..\documents\github\aspen-python\aspen\testing\client.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.website.Website object at 0x00000000032EC080>
environ = {'CONTENT_TYPE': 'multipart/form-data; boundary=BoUnDaRyStRiNg', 'HTTP_COOKIE': '', 'HTTP_HOST': 'localhost', 'PATH_INFO': '/', ...}
raise_immediately = True, return_after = None
def respond(self, environ, raise_immediately=None, return_after=None):
"""Given a WSGI environ, return a state dict.
"""
return self.algorithm.run( website=self
, environ=environ
, _raise_immediately=raise_immediately
> , _return_after=return_after
)
..\..\..\..\documents\github\aspen-python\aspen\website.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <algorithm.Algorithm object at 0x00000000032EC128>
_raise_immediately = True, _return_after = None
state = {'algorithm': <algorithm.Algorithm object at 0x00000000032EC128>, 'environ': {'CONTENT_TYPE': 'multipart/form-data; bo... / HTTP/1.1\r\nContent-Type: multipart/form-data; boundary=BoUnDaRyStRiNg\r\nHost: localhost\r\nCookie: \r\n\r\n', ...}
function = <function get_resource_for_request at 0x00000000033A7CF8>
function_name = 'get_resource_for_request'
deps = Dependencies(as_args=('GET / HTTP/1.1\r\nContent-Type: multipart/form-data; bo...meters=('request', 'response'), required=('request', 'response'), optional={}))
have_exception = False, new_state = {'response': None}
ExceptionClass = <class 'aspen.exceptions.LoadError'>
exception = LoadError('Traceback (most recent call last):\n File "c:\\users\\benjamin\\do...rs\\\\benjamin\\\\appdata\\\\local\\\\temp\\\\filesystem-tree-funizz\\\\\'\n',)
def run(self, _raise_immediately=None, _return_after=None, **state):
"""Run through the functions in the :py:attr:`functions` list.
:param bool _raise_immediately: if not ``None``, will override any
default for ``raise_immediately`` that was set in the constructor
:param str _return_after: if not ``None``, return after calling the function
with this name
:param dict state: remaining keyword arguments are used for the initial
state dictionary for this run of the algorithm
:raises: :py:exc:`FunctionNotFound`, if there is no function named
``_return_after``
:returns: a dictionary representing the final algorithm state
The state dictionary is initialized with three items (their default
values can be overriden using keyword arguments to :py:func:`run`):
- ``algorithm`` - a reference to the parent :py:class:`Algorithm` instance
- ``state`` - a circular reference to the state dictionary
- ``exception`` - ``None``
For each function in the :py:attr:`functions` list, we look at the
function signature and compare it to the current value of ``exception``
in the state dictionary. If ``exception`` is ``None`` then we skip any
function that asks for ``exception``, and if ``exception`` is *not*
``None`` then we only call functions that *do* ask for it. The upshot
is that any function that raises an exception will cause us to
fast-forward to the next exception-handling function in the list.
Here are some further notes on exception handling:
- If a function provides a default value for ``exception``, then that
function will be called whether or not there is an exception being
handled.
- You should return ``{'exception': None}`` to reset exception
handling. Under Python 2 we will call ``sys.exc_clear`` for you
(under Python 3 exceptions are cleared automatically at the end of
except blocks).
- If ``exception`` is not ``None`` after all functions have been run,
then we re-raise it.
- If ``raise_immediately`` evaluates to ``True`` (looking first at any
per-call ``_raise_immediately`` and then at the instance default),
then we re-raise any exception immediately instead of
fast-forwarding to the next exception handler.
"""
if _raise_immediately is None:
_raise_immediately = self.default_raise_immediately
if _return_after is not None:
if _return_after not in self.get_names():
raise FunctionNotFound(_return_after)
if 'algorithm' not in state: state['algorithm'] = self
if 'state' not in state: state['state'] = state
if 'exception' not in state: state['exception'] = None
for function in self.functions:
function_name = function.__name__
try:
deps = resolve_dependencies(function, state)
have_exception = state['exception'] is not None
if 'exception' in deps.signature.required and not have_exception:
pass # Function wants exception but we don't have it.
elif 'exception' not in deps.signature.parameters and have_exception:
pass # Function doesn't want exception but we have it.
else:
> new_state = function(**deps.as_kwargs)
..\..\..\..\Documents\GitHub\aspen-python\env\lib\site-packages\algorithm.py:288:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = 'GET / HTTP/1.1\r\nContent-Type: multipart/form-data; boundary=BoUnDaRyStRiNg\r\nHost: localhost\r\nCookie: \r\n\r\n'
response = None
def get_resource_for_request(request, response):
if response is None:
> return {'resource': resources.get(request)}
..\..\..\..\documents\github\aspen-python\aspen\algorithms\website.py:87:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = 'GET / HTTP/1.1\r\nContent-Type: multipart/form-data; boundary=BoUnDaRyStRiNg\r\nHost: localhost\r\nCookie: \r\n\r\n'
def get(request):
"""Given a Request, return a Resource object (with caching).
We need the request because it carries media_type_default.
"""
# XXX This is not thread-safe. It used to be, but then I simplified it
# when I switched to diesel. Now that we have multiple engines, some of
# which are threaded, we need to make this thread-safe again.
# Get a cache Entry object.
# =========================
if request.fs not in __cache__:
entry = Entry()
__cache__[request.fs] = entry
entry = __cache__[request.fs]
# Process the resource.
# =====================
mtime = os.stat(request.fs)[stat.ST_MTIME]
if entry.mtime == mtime: # cache hit
if entry.exc is not None:
raise entry.exc
else: # cache miss
try:
entry.resource = load(request, mtime)
except: # capture any Exception
entry.exc = (LoadError(traceback.format_exc())
, sys.exc_info()[2]
)
else: # reset any previous Exception
entry.exc = None
entry.mtime = mtime
if entry.exc is not None:
> raise entry.exc[0] # TODO Why [0] here, and not above?
E LoadError: Traceback (most recent call last):
E File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 142, in get
E entry.resource = load(request, mtime)
E File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 78, in load
E raw_fh = open(request.fs, 'rb')
E IOError: [Errno 2] No such file or directory: u'c:\\users\\benjamin\\appdata\\local\\temp\\filesystem-tree-funizz\\'
..\..\..\..\documents\github\aspen-python\aspen\resources\__init__.py:152: LoadError
_________________ test_transport_GET_blocks_for_empty_socket __________________
harness = <aspen.testing.harness.Harness object at 0x000000000332E908>
def test_transport_GET_blocks_for_empty_socket(harness):
transport = harness.make_transport(state=1)
request = harness.make_socket_request()
start = time.time()
transport.respond(request)
end = time.time()
expected = transport.timeout
actual = round(end - start, 4)
> assert actual > expected
E assert 0.05 > 0.05
..\..\..\..\Documents\GitHub\aspen-python\tests\test_sockets_transport.py:95: AssertionError
__________________________ test_to_age_barely_works ___________________________
def test_to_age_barely_works():
actual = to_age(utcnow())
> assert actual == "just a moment ago"
E assert 'in just a moment' == 'just a moment ago'
E - in just a moment
E ? ---
E + just a moment ago
E ? ++++
tests\test_utils.py:46: AssertionError
________________________ test_to_age_formatting_works _________________________
def test_to_age_formatting_works():
actual = to_age(utcnow(), fmt_past="Cheese, for %(age)s!")
> assert actual == "Cheese, for just a moment!"
E assert 'in just a moment' == 'Cheese, for just a moment!'
E - in just a moment
E + Cheese, for just a moment!
tests\test_utils.py:53: AssertionError
_______________ test_default_error_spt_handles_application_json _______________
harness = <aspen.testing.harness.Harness object at 0x0000000003340A58>
def test_default_error_spt_handles_application_json(harness):
harness.fs.www.mk(('foo.json.spt',"""
from aspen import Response
[---]
raise Response(404)
[---]
"""))
response = harness.client.GET('/foo.json', raise_immediately=False)
assert response.code == 404
assert response.headers['Content-Type'] == 'application/json'
> assert response.body == '''\
{ "error_code": 404
, "error_message_short": "Not Found"
, "error_message_long": ""
}
'''
E assert '{ "error_cod... ""\r\n }\r\n' == '{ "error_code...long": ""\n }\n'
E - { "error_code": 404\r
E ? --
E + { "error_code": 404
E - , "error_message_short": "Not Found"\r
E ? --
E + , "error_message_short": "Not Found"
E - , "error_message_long": ""\r
E ? --
E + , "error_message_long": ""
E - }\r
E + }
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:162: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 404 Not Found /foo.json ...n\aspen\www\error.spt
__ test_default_error_spt_application_json_includes_msg_for_show_tracebacks ___
harness = <aspen.testing.harness.Harness object at 0x0000000003342278>
def test_default_error_spt_application_json_includes_msg_for_show_tracebacks(harness):
harness.client.website.show_tracebacks = True
harness.fs.www.mk(('foo.json.spt',"""
from aspen import Response
[---]
raise Response(404, "Right, sooo...")
[---]
"""))
response = harness.client.GET('/foo.json', raise_immediately=False)
assert response.code == 404
assert response.headers['Content-Type'] == 'application/json'
> assert response.body == '''\
{ "error_code": 404
, "error_message_short": "Not Found"
, "error_message_long": "Right, sooo..."
}
'''
E assert '{ "error_cod....."\r\n }\r\n' == '{ "error_code... sooo..."\n }\n'
E - { "error_code": 404\r
E ? --
E + { "error_code": 404
E - , "error_message_short": "Not Found"\r
E ? --
E + , "error_message_short": "Not Found"
E - , "error_message_long": "Right, sooo..."\r
E ? --
E + , "error_message_long": "Right, sooo..."
E - }\r
E + }
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:180: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 404 Not Found /foo.json ...n\aspen\www\error.spt
_____________ test_default_error_spt_falls_through_to_text_plain ______________
harness = <aspen.testing.harness.Harness object at 0x00000000033362B0>
def test_default_error_spt_falls_through_to_text_plain(harness):
harness.fs.www.mk(('foo.xml.spt',"""
from aspen import Response
[---]
raise Response(404)
[---]
"""))
response = harness.client.GET('/foo.xml', raise_immediately=False)
assert response.code == 404
assert response.headers['Content-Type'] == 'text/plain; charset=UTF-8'
> assert response.body == "Not found, program!\n\n"
E assert 'Not found, program!\r\n\r\n' == 'Not found, program!\n\n'
E - Not found, program!\r
E ? --
E + Not found, program!
E - \r
E +
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:197: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 404 Not Found /foo.xml ...n\aspen\www\error.spt
____ test_default_error_spt_fall_through_includes_msg_for_show_tracebacks _____
harness = <aspen.testing.harness.Harness object at 0x00000000026E05C0>
def test_default_error_spt_fall_through_includes_msg_for_show_tracebacks(harness):
harness.client.website.show_tracebacks = True
harness.fs.www.mk(('foo.xml.spt',"""
from aspen import Response
[---]
raise Response(404, "Try again!")
[---]
"""))
response = harness.client.GET('/foo.xml', raise_immediately=False)
assert response.code == 404
assert response.headers['Content-Type'] == 'text/plain; charset=UTF-8'
> assert response.body == "Not found, program!\nTry again!\n"
E assert 'Not found, p...ry again!\r\n' == 'Not found, pr...!\nTry again!\n'
E - Not found, program!\r
E ? --
E + Not found, program!
E - Try again!\r
E ? --
E + Try again!
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:210: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 404 Not Found /foo.xml ...n\aspen\www\error.spt
__________________ test_autoindex_response_is_404_by_default __________________
harness = <aspen.testing.harness.Harness object at 0x0000000003352128>
def test_autoindex_response_is_404_by_default(harness):
harness.fs.www.mk(('README', "Greetings, program!"))
> assert harness.client.GET(raise_immediately=False).code == 404
E assert 500 == 404
E + where 500 = <Response: 500 Internal Server Error>.code
E + where <Response: 500 Internal Server Error> = <bound method Client.GET of <aspen.testing.client.Client object at 0x0000000003352780>>(raise_immediately=False)
E + where <bound method Client.GET of <aspen.testing.client.Client object at 0x0000000003352780>> = <aspen.testing.client.Client object at 0x0000000003352780>.GET
E + where <aspen.testing.client.Client object at 0x0000000003352780> = <aspen.testing.harness.Harness object at 0x0000000003352128>.client
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:247: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\Users\Benjamin\Documents\GitHub\aspen-python\env\lib\site-packages\algorithm.py", line 288, in run
pid-5688 thread-5628 (MainThread) new_state = function(**deps.as_kwargs)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\algorithms\website.py", line 87, in get_resource_for_request
pid-5688 thread-5628 (MainThread) return {'resource': resources.get(request)}
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 152, in get
pid-5688 thread-5628 (MainThread) raise entry.exc[0] # TODO Why [0] here, and not above?
pid-5688 thread-5628 (MainThread) LoadError: Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 142, in get
pid-5688 thread-5628 (MainThread) entry.resource = load(request, mtime)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 78, in load
pid-5688 thread-5628 (MainThread) raw_fh = open(request.fs, 'rb')
pid-5688 thread-5628 (MainThread) IOError: [Errno 2] No such file or directory: u'c:\\users\\benjamin\\appdata\\local\\temp\\filesystem-tree-yjh8hj\\'
pid-5688 thread-5628 (MainThread)
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 500 Internal Server Error / ...n\aspen\www\error.spt
_____________________ test_autoindex_response_is_returned _____________________
harness = <aspen.testing.harness.Harness object at 0x00000000033C80F0>
def test_autoindex_response_is_returned(harness):
harness.fs.www.mk(('README', "Greetings, program!"))
harness.client.website.list_directories = True
body = harness.client.GET(raise_immediately=False).body
> assert 'README' in body
E assert 'README' in '<html>\r\n <head>\r\n <title>500 Internal Server Error</title>\r\n <style>\r\n \r\n ... </head>\r\n <body>\r\n Internal server error, program!\r\n <pre></pre>\r\n </body>\r\n</html>\r\n'
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:253: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\Users\Benjamin\Documents\GitHub\aspen-python\env\lib\site-packages\algorithm.py", line 288, in run
pid-5688 thread-5628 (MainThread) new_state = function(**deps.as_kwargs)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\algorithms\website.py", line 87, in get_resource_for_request
pid-5688 thread-5628 (MainThread) return {'resource': resources.get(request)}
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 152, in get
pid-5688 thread-5628 (MainThread) raise entry.exc[0] # TODO Why [0] here, and not above?
pid-5688 thread-5628 (MainThread) LoadError: Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 142, in get
pid-5688 thread-5628 (MainThread) entry.resource = load(request, mtime)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 78, in load
pid-5688 thread-5628 (MainThread) raw_fh = open(request.fs, 'rb')
pid-5688 thread-5628 (MainThread) IOError: [Errno 2] No such file or directory: u'c:\\users\\benjamin\\appdata\\local\\temp\\filesystem-tree-7muf7l\\'
pid-5688 thread-5628 (MainThread)
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 500 Internal Server Error / ...n\aspen\www\error.spt
_______________________ test_call_wraps_wsgi_middleware _______________________
client = <aspen.testing.client.Client object at 0x0000000003352278>
def test_call_wraps_wsgi_middleware(client):
client.website.algorithm.default_short_circuit = False
client.website.wsgi_app = TestMiddleware(client.website.wsgi_app)
respond = [False, False]
def start_response_should_404(status, headers):
assert status.lower().strip() == '404 not found'
respond[0] = True
> client.website(build_environ('/'), start_response_should_404)
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.website.Website object at 0x0000000003336A90>
environ = {'PATH_INFO': '/', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SERVER_PROTOCOL': 'HTTP/1.1', ...}
start_response = <function start_response_should_404 at 0x00000000033E1F28>
def __call__(self, environ, start_response):
# back-compatibility for network engines
> return self.wsgi_app(environ, start_response)
..\..\..\..\documents\github\aspen-python\aspen\website.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <test_website.TestMiddleware object at 0x00000000033367B8>
environ = {'PATH_INFO': '/', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SERVER_PROTOCOL': 'HTTP/1.1', ...}
start_response = <function start_response_should_404 at 0x00000000033E1F28>
def __call__(self, environ, start_response):
if environ['PATH_INFO'] == '/middleware':
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['TestMiddleware']
> return self.app(environ, start_response)
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:291:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <aspen.website.Website object at 0x0000000003336A90>
environ = {'PATH_INFO': '/', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SERVER_PROTOCOL': 'HTTP/1.1', ...}
start_response = <function start_response_should_404 at 0x00000000033E1F28>
def wsgi_app(self, environ, start_response):
"""WSGI interface.
Wrap this method (instead of the website object itself) when you want
to use WSGI middleware::
website = Website()
website.wsgi = WSGIMiddleware(website.wsgi)
"""
wsgi = self.respond(environ)['response']
> return wsgi(environ, start_response)
..\..\..\..\documents\github\aspen-python\aspen\website.py:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response: 500 Internal Server Error>
environ = {'PATH_INFO': '/', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SERVER_PROTOCOL': 'HTTP/1.1', ...}
start_response = <function start_response_should_404 at 0x00000000033E1F28>
def __call__(self, environ, start_response):
wsgi_status = str(self)
for morsel in self.headers.cookie.values():
self.headers.add('Set-Cookie', morsel.OutputString())
wsgi_headers = []
for k, vals in self.headers.iteritems():
try: # XXX This is a hack. It's red hot, baby.
k = k.encode('US-ASCII')
except UnicodeEncodeError:
k = ascii_dammit(k)
raise ValueError("Header key %s must be US-ASCII.")
for v in vals:
try: # XXX This also is a hack. It is also red hot, baby.
v = v.encode('US-ASCII')
except UnicodeEncodeError:
v = ascii_dammit(v)
raise ValueError("Header value %s must be US-ASCII.")
wsgi_headers.append((k, v))
> start_response(wsgi_status, wsgi_headers)
..\..\..\..\documents\github\aspen-python\aspen\http\response.py:112:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
status = '500 Internal Server Error'
headers = [('Content-Type', 'text/html; charset=UTF-8')]
def start_response_should_404(status, headers):
> assert status.lower().strip() == '404 not found'
E assert '500 internal server error' == '404 not found'
E - 500 internal server error
E + 404 not found
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website.py:309: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\Users\Benjamin\Documents\GitHub\aspen-python\env\lib\site-packages\algorithm.py", line 288, in run
pid-5688 thread-5628 (MainThread) new_state = function(**deps.as_kwargs)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\algorithms\website.py", line 87, in get_resource_for_request
pid-5688 thread-5628 (MainThread) return {'resource': resources.get(request)}
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 152, in get
pid-5688 thread-5628 (MainThread) raise entry.exc[0] # TODO Why [0] here, and not above?
pid-5688 thread-5628 (MainThread) LoadError: Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 142, in get
pid-5688 thread-5628 (MainThread) entry.resource = load(request, mtime)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 78, in load
pid-5688 thread-5628 (MainThread) raw_fh = open(request.fs, 'rb')
pid-5688 thread-5628 (MainThread) IOError: [Errno 2] No such file or directory: u'c:\\users\\benjamin\\appdata\\local\\temp\\filesystem-tree-fq6kpi\\'
pid-5688 thread-5628 (MainThread)
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 500 Internal Server Error / ...n\aspen\www\error.spt
___________________________ test_404_comes_out_404 ____________________________
harness = <aspen.testing.harness.Harness object at 0x0000000003367908>
def test_404_comes_out_404(harness):
harness.fs.project.mk(('404.spt', '[---]\n[---] text/plain\nEep!'))
> assert harness.client.GET(raise_immediately=False).code == 404
E assert 500 == 404
E + where 500 = <Response: 500 Internal Server Error>.code
E + where <Response: 500 Internal Server Error> = <bound method Client.GET of <aspen.testing.client.Client object at 0x0000000003367780>>(raise_immediately=False)
E + where <bound method Client.GET of <aspen.testing.client.Client object at 0x0000000003367780>> = <aspen.testing.client.Client object at 0x0000000003367780>.GET
E + where <aspen.testing.client.Client object at 0x0000000003367780> = <aspen.testing.harness.Harness object at 0x0000000003367908>.client
..\..\..\..\Documents\GitHub\aspen-python\tests\test_website_flow.py:14: AssertionError
------------------------------- Captured stdout -------------------------------
pid-5688 thread-5628 (MainThread) Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\Users\Benjamin\Documents\GitHub\aspen-python\env\lib\site-packages\algorithm.py", line 288, in run
pid-5688 thread-5628 (MainThread) new_state = function(**deps.as_kwargs)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\algorithms\website.py", line 87, in get_resource_for_request
pid-5688 thread-5628 (MainThread) return {'resource': resources.get(request)}
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 152, in get
pid-5688 thread-5628 (MainThread) raise entry.exc[0] # TODO Why [0] here, and not above?
pid-5688 thread-5628 (MainThread) LoadError: Traceback (most recent call last):
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 142, in get
pid-5688 thread-5628 (MainThread) entry.resource = load(request, mtime)
pid-5688 thread-5628 (MainThread) File "c:\users\benjamin\documents\github\aspen-python\aspen\resources\__init__.py", line 78, in load
pid-5688 thread-5628 (MainThread) raw_fh = open(request.fs, 'rb')
pid-5688 thread-5628 (MainThread) IOError: [Errno 2] No such file or directory: u'c:\\users\\benjamin\\appdata\\local\\temp\\filesystem-tree-sbranf\\'
pid-5688 thread-5628 (MainThread)
pid-5688 thread-5628 (MainThread) Cannot import pygments: No module named pygments.lexers
pid-5688 thread-5628 (MainThread) 500 Internal Server Error / ...n\aspen\www\error.spt
========= 13 failed, 511 passed, 3 skipped, 1 xfailed in 3.94 seconds =========
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment