Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #124: Convert forgotten attr-access-->dict-access. #128

Merged
merged 4 commits into from
Mar 22, 2016

Conversation

mplanchard
Copy link
Contributor

Incorporated changes from @ankostis PR #127 and added a test that fails on current master with the same error message as in #124, but succeeds with changed code.

Test fails with the following error message, as seen in #124:

(Python35)[Nautilus@Nautilus-2 pypiserver]$ py.test tests/test_init.py 
====================================================================================== test session starts ======================================================================================
platform darwin -- Python 3.5.0, pytest-2.8.7, py-1.4.31, pluggy-0.3.1
rootdir: /Users/Nautilus/Documents/Programming/ihiji/pypiserver, inifile: tox.ini
plugins: cov-2.2.1
collected 3 items 

tests/test_init.py FFF

=========================================================================================== FAILURES ============================================================================================
_____________________________________________________________________________ test_paste_app_factory[conf_options0] _____________________________________________________________________________

conf_options = {}

    @pytest.mark.parametrize('conf_options', [
        {},
        {'root': '~/stable_packages'},
        {'root': '~/unstable_packages', 'authenticated': 'upload',
         'passwords': '~/htpasswd'}
    ])
    def test_paste_app_factory(conf_options):
        """Test the paste_app_factory method"""
>       res_app = pypiserver.paste_app_factory({}, **conf_options)

tests/test_init.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../Python35/lib/python3.5/site-packages/pypiserver/__init__.py:154: in paste_app_factory
    upd_bool_attr_from_dict_str_item(c, 'redirect_to_fallback', local_conf)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

conf = {'VERSION': '1.1.10', 'authenticated': ['update'], 'auther': None, 'cache_control': None, ...}, attr = 'redirect_to_fallback', sdict = {}

    def upd_bool_attr_from_dict_str_item(conf, attr, sdict):
>       setattr(conf, attr, str2bool(sdict.pop(attr, None), getattr(conf, attr)))
E       AttributeError: 'dict' object has no attribute 'redirect_to_fallback'

../../Python35/lib/python3.5/site-packages/pypiserver/__init__.py:140: AttributeError
_____________________________________________________________________________ test_paste_app_factory[conf_options1] _____________________________________________________________________________

conf_options = {'root': '~/stable_packages'}

    @pytest.mark.parametrize('conf_options', [
        {},
        {'root': '~/stable_packages'},
        {'root': '~/unstable_packages', 'authenticated': 'upload',
         'passwords': '~/htpasswd'}
    ])
    def test_paste_app_factory(conf_options):
        """Test the paste_app_factory method"""
>       res_app = pypiserver.paste_app_factory({}, **conf_options)

tests/test_init.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

global_config = {}, local_conf = {'root': '~/stable_packages'}, upd_bool_attr_from_dict_str_item = <function paste_app_factory.<locals>.upd_bool_attr_from_dict_str_item at 0x103848d08>
c = {'VERSION': '1.1.10', 'authenticated': ['update'], 'auther': None, 'cache_control': None, ...}, root = '~/stable_packages'

    def paste_app_factory(global_config, **local_conf):
        import os

        def upd_bool_attr_from_dict_str_item(conf, attr, sdict):
            setattr(conf, attr, str2bool(sdict.pop(attr, None), getattr(conf, attr)))

        def _make_root(root):
            root = root.strip()
            if root.startswith("~"):
                return os.path.expanduser(root)
            return root

        c = default_config()

        root = local_conf.get("root")
        if root:
>           c.root = [_make_root(x) for x in root.split("\n") if x.strip()]
E           AttributeError: 'dict' object has no attribute 'root'

../../Python35/lib/python3.5/site-packages/pypiserver/__init__.py:152: AttributeError
_____________________________________________________________________________ test_paste_app_factory[conf_options2] _____________________________________________________________________________

conf_options = {'authenticated': 'upload', 'passwords': '~/htpasswd', 'root': '~/unstable_packages'}

    @pytest.mark.parametrize('conf_options', [
        {},
        {'root': '~/stable_packages'},
        {'root': '~/unstable_packages', 'authenticated': 'upload',
         'passwords': '~/htpasswd'}
    ])
    def test_paste_app_factory(conf_options):
        """Test the paste_app_factory method"""
>       res_app = pypiserver.paste_app_factory({}, **conf_options)

tests/test_init.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

global_config = {}, local_conf = {'authenticated': 'upload', 'passwords': '~/htpasswd', 'root': '~/unstable_packages'}
upd_bool_attr_from_dict_str_item = <function paste_app_factory.<locals>.upd_bool_attr_from_dict_str_item at 0x1038710d0>
c = {'VERSION': '1.1.10', 'authenticated': ['update'], 'auther': None, 'cache_control': None, ...}, root = '~/unstable_packages'

    def paste_app_factory(global_config, **local_conf):
        import os

        def upd_bool_attr_from_dict_str_item(conf, attr, sdict):
            setattr(conf, attr, str2bool(sdict.pop(attr, None), getattr(conf, attr)))

        def _make_root(root):
            root = root.strip()
            if root.startswith("~"):
                return os.path.expanduser(root)
            return root

        c = default_config()

        root = local_conf.get("root")
        if root:
>           c.root = [_make_root(x) for x in root.split("\n") if x.strip()]
E           AttributeError: 'dict' object has no attribute 'root'

../../Python35/lib/python3.5/site-packages/pypiserver/__init__.py:152: AttributeError
=================================================================================== 3 failed in 0.05 seconds ====================================================================================

@mplanchard mplanchard added this to the Next 1.2.x Release milestone Mar 22, 2016
ankostis added a commit that referenced this pull request Mar 22, 2016
FIX #124: Convert forgotten attr-access-->dict-access & TCs for paste-factory
@ankostis ankostis merged commit 5d2e56a into pypiserver:master Mar 22, 2016
@mplanchard mplanchard deleted the mp_fixpaste branch March 22, 2016 13:49
michaelkuty pushed a commit to michaelkuty/pypiserver that referenced this pull request Jun 27, 2016
FIX pypiserver#124: Convert forgotten attr-access-->dict-access & TCs for paste-factory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants