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

TypeError when no arguments supplied #14

Closed
jaraco opened this issue May 12, 2017 · 2 comments
Closed

TypeError when no arguments supplied #14

jaraco opened this issue May 12, 2017 · 2 comments

Comments

@jaraco
Copy link
Contributor

jaraco commented May 12, 2017

Consider this watcher_getter:

 proc = watcher_getter(
        name='/home/vagrant/.virtualenvs/gryphon/services/dragoman/bin/dragoman',
        kwargs=dict(
            env=dict(
                PORT=str(port),
                STORAGE_URI=dragoman_db_uri,
            ),
        ),
        checker=functools.partial(airportlocker_listening, port),
    )

Causes this TypeError:

name = '/home/vagrant/.virtualenvs/gryphon/services/dragoman/bin/dragoman', arguments = None
kwargs = {'env': {'PORT': '9000', 'STORAGE_URI': "mongodb://['localhost:47667']/translations"}}
timeout = 20, checker = <functools.partial object at 0x7fef84e1e730>

    def watcher_getter_function(name, arguments=None, kwargs=None, timeout=20, checker=None):
        executable = find_executable(name)
        assert executable, 'You have to install {0} executable.'.format(name)
    
>       cmd = [name] + arguments or []
E       TypeError: can only concatenate list (not "NoneType") to list

/home/vagrant/.virtualenvs/gryphon/local/lib/python2.7/site-packages/pytest_services/service.py:63: TypeError

The issue is with the bind order of that expression. A distilled example is this:

>>> [] + None or []
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "NoneType") to list

Probably what was intended was this:

>>> [] + (None or [])
[]

One can workaround the problem by supplying arguments=[], but it would be better if services handled its own defaults.

@bubenkoff
Copy link
Member

service_path is a string fixture, in your example instead you use it as a function, any reason why?
just concatenate with os.path?

@jaraco
Copy link
Contributor Author

jaraco commented May 13, 2017

Oh, I wasn't aware of service_path. In this case, it's a global privately defined. It returns a string. I'll update the example to eliminate that point of confusion.

jaraco added a commit that referenced this issue May 15, 2017
bubenkoff added a commit that referenced this issue May 15, 2017
Force proper expression order. Fixes #14.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants