Created
September 29, 2015 11:31
-
-
Save piotr-dobrogost/35a3521d02a50938990c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/home/piotr/projects/kotti_content_proxy/env/bin/python /home/piotr/apps/pycharm-4.5.3/helpers/pycharm/pytestrunner.py -p pytest_teamcity kotti_content_proxy/tests | |
Testing started at 1:30 PM ... | |
============================= test session starts ============================== | |
platform linux2 -- Python 2.7.10, pytest-2.8.0, py-1.4.30, pluggy-0.3.1 | |
rootdir: /home/piotr/projects/kotti_content_proxy, inifile: setup.cfg | |
plugins: Kotti-1.2.0, xdist-1.13.1, pep8-1.0.6, cov-2.1.0, pycharm-0.3.0 | |
collected 13 items | |
kotti_content_proxy/__init__.py . | |
kotti_content_proxy/resources.py F | |
/home/piotr/projects/kotti_content_proxy/kotti_content_proxy/resources.py:65:80: E501 line too long (83 > 79 characters) | |
proxied_attrs = super(ContentProxy, self).__getattribute__('proxied_attrs') | |
^ | |
kotti_content_proxy/views.py . | |
kotti_content_proxy/tests/conftest.py . | |
kotti_content_proxy/tests/test_models.py .F | |
Traceback (most recent call last): | |
File "/home/piotr/projects/kotti_content_proxy/kotti_content_proxy/tests/test_models.py", line 15, in test_model | |
root['proxy'] = ContentProxy(proxied_id=doc.id, title=u'proxied about') | |
File "<string>", line 2, in __init__ | |
File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/sqlalchemy/orm/instrumentation.py", line 337, in _new_state_if_none | |
elif self.class_ is not instance.__class__ and \ | |
File "/home/piotr/projects/kotti_content_proxy/kotti_content_proxy/resources.py", line 67, in __getattribute__ | |
if key in proxied_attrs: | |
TypeError: argument of type 'NoneType' is not iterable | |
kotti_content_proxy/tests/test_views.py . | |
INTERNALERROR> Traceback (most recent call last): | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/main.py", line 90, in wrap_session | |
INTERNALERROR> session.exitstatus = doit(config, session) or 0 | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/main.py", line 121, in _main | |
INTERNALERROR> config.hook.pytest_runtestloop(session=session) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__ | |
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec | |
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda> | |
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute() | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute | |
INTERNALERROR> res = hook_impl.function(*args) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/main.py", line 146, in pytest_runtestloop | |
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__ | |
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec | |
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda> | |
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute() | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute | |
INTERNALERROR> return _wrapped_call(hook_impl.function(*args), self.execute) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 253, in _wrapped_call | |
INTERNALERROR> return call_outcome.get_result() | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result | |
INTERNALERROR> _reraise(*ex) # noqa | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 264, in __init__ | |
INTERNALERROR> self.result = func() | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute | |
INTERNALERROR> res = hook_impl.function(*args) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/runner.py", line 65, in pytest_runtest_protocol | |
INTERNALERROR> runtestprotocol(item, nextitem=nextitem) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/runner.py", line 72, in runtestprotocol | |
INTERNALERROR> rep = call_and_report(item, "setup", log) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/runner.py", line 121, in call_and_report | |
INTERNALERROR> report = hook.pytest_runtest_makereport(item=item, call=call) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__ | |
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec | |
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda> | |
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute() | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute | |
INTERNALERROR> return _wrapped_call(hook_impl.function(*args), self.execute) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call | |
INTERNALERROR> wrap_controller.send(call_outcome) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/skipping.py", line 170, in pytest_runtest_makereport | |
INTERNALERROR> rep = outcome.get_result() | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result | |
INTERNALERROR> _reraise(*ex) # noqa | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 264, in __init__ | |
INTERNALERROR> self.result = func() | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute | |
INTERNALERROR> res = hook_impl.function(*args) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/runner.py", line 227, in pytest_runtest_makereport | |
INTERNALERROR> style=item.config.option.tbstyle) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/python.py", line 715, in _repr_failure_py | |
INTERNALERROR> style=style) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/main.py", line 397, in _repr_failure_py | |
INTERNALERROR> self._prunetraceback(excinfo) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/python.py", line 698, in _prunetraceback | |
INTERNALERROR> ntraceback = ntraceback.filter(filter_traceback) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/py/_code/code.py", line 299, in filter | |
INTERNALERROR> return Traceback(filter(fn, self)) | |
INTERNALERROR> File "/home/piotr/projects/kotti_content_proxy/env/lib/python2.7/site-packages/_pytest/python.py", line 49, in filter_traceback | |
INTERNALERROR> return entry.path != cutdir1 and not entry.path.relto(cutdir2) | |
INTERNALERROR> AttributeError: 'str' object has no attribute 'relto' | |
====================== 2 failed, 5 passed in 0.94 seconds ====================== | |
Process finished with exit code 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on 2014-09-23 | |
:author: Andreas Kaiser (disko) | |
""" | |
from kotti.resources import Content | |
from sqlalchemy import Column | |
from sqlalchemy import ForeignKey | |
from sqlalchemy import Integer | |
from sqlalchemy.orm import relationship | |
from kotti_content_proxy import _ | |
class ContentProxy(Content): | |
""" A ContentProxy refers to any other content node in the site. """ | |
id = Column( | |
Integer, | |
ForeignKey('contents.id'), | |
primary_key=True) | |
proxied_id = Column( | |
Integer, | |
ForeignKey('contents.id'), | |
nullable=False) | |
proxied_object = relationship(Content, foreign_keys=[proxied_id]) | |
proxied_attrs = None | |
__mapper_args__ = Content.__mapper_args__.copy() | |
__mapper_args__.update({ | |
'inherit_condition': (id == Content.id), | |
'polymorphic_identity': 'content_proxy', | |
}) | |
type_info = Content.type_info.copy( | |
name=u'ContentProxy', | |
title=_(u'Content Proxy'), | |
add_view=u'add_content_proxy', | |
addable_to=[u'Document'], | |
) | |
def __init__(self, proxied_id=None, proxied_attrs=None, **kwargs): | |
""" Constructor | |
:param proxied_id: id of the proxied object | |
:type proxied_id: int | |
:param **kwargs: see :class:`kotti.resources.Content` | |
:type **kwargs: variant | |
""" | |
super(ContentProxy, self).__init__(**kwargs) | |
self.proxied_id = proxied_id | |
proxied_attrs = tuple(proxied_attrs) if proxied_attrs else tuple() | |
self.proxied_attrs = ('__acl__', ) + proxied_attrs | |
def __getattribute__(self, key): | |
""" Proxy some attributes. | |
See https://www.inkling.com/read/learning-python-mark-lutz-4th/chapter-37/--getattr---and---getattribute-- # noqa | |
""" | |
proxied_attrs = super(ContentProxy, self).__getattribute__('proxied_attrs') | |
if key in proxied_attrs: | |
return self.proxied_object.__getattribute__(key) | |
return super(ContentProxy, self).__getattribute__(key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment