# Buggy code
def search(self, query):
    results = []

    search = {"q": query}

    response = session().get(self._url + "search", params=search)
    content = parse(response.content, namespaceHTMLElements=False)
    for result in content.findall(".//*[@class='package-snippet']"):
        name = result.find("h3/*[@class='package-snippet__name']").text
        version = result.find("h3/*[@class='package-snippet__version']").text

        if not name or not version:
            continue

        description = result.find("p[@class='package-snippet__description']").text
        if not description:
            description = ""

        try:
            result = Package(name, version, description)
            result.description = to_str(description.strip())
            results.append(result)
        except ParseVersionError:
            self._log(
                'Unable to parse version "{}" for the {} package, skipping'.format(
                    version, name
                ),
                level="debug",
            )

    return results


# Traceback (EnvCommandError)
$ poetry add my_package -vvv
Using virtualenv: /Users/thopper/c/poetry-test/env
PyPI: No packages found for my_package *
example-pypi: 2 packages found for my_package *
Using version ^0.2.0 for my_package

Updating dependencies
Resolving dependencies...
1: fact: poetry-test is 0.1.0
1: derived: poetry-test
1: fact: poetry-test depends on my_package (^0.2.0)
1: selecting poetry-test (0.1.0)
1: derived: my_package (^0.2.0)
PyPI: No packages found for my_package >=0.2.0,<0.3.0
example-pypi: 1 packages found for my_package >=0.2.0,<0.3.0
PyPI: Getting info for my_package (0.2.0) from PyPI
1: fact: my_package (0.2.0) depends on internal-yoyo-migrations (*)
1: fact: my_package (0.2.0) depends on jinja2 (*)
1: fact: my_package (0.2.0) depends on psycopg2-binary (*)
1: fact: my_package (0.2.0) depends on python-sql (*)
1: selecting my_package (0.2.0)
1: derived: python-sql (*)
1: derived: psycopg2-binary (*)
1: derived: jinja2 (*)
1: derived: internal-yoyo-migrations (*)
1: selecting python-sql (1.0.0)
1: selecting psycopg2-binary (2.8.4)
1: fact: jinja2 (2.10.3) depends on MarkupSafe (>=0.23)
1: selecting jinja2 (2.10.3)
1: derived: MarkupSafe (>=0.23)
PyPI: Getting info for internal-yoyo-migrations (6.1.1) from PyPI
1: fact: internal-yoyo-migrations (6.1.1) depends on text-unidecode (*)
1: fact: internal-yoyo-migrations (6.1.1) depends on iniherit (*)
1: selecting internal-yoyo-migrations (6.1.1)
1: derived: iniherit (*)
1: derived: text-unidecode (*)
1: selecting markupsafe (1.1.1)
1: fact: iniherit (0.3.9) depends on six (>=1.6.1)
1: selecting iniherit (0.3.9)
1: derived: six (>=1.6.1)
1: selecting text-unidecode (1.3)
1: selecting six (1.14.0)
1: Version solving took 0.463 seconds.
1: Tried 1 solutions.

Writing lock file


Package operations: 9 installs, 0 updates, 0 removals

- Installing six (1.14.0)
- Installing iniherit (0.3.9)
- Installing markupsafe (1.1.1)
- Installing text-unidecode (1.3)
- Installing internal-yoyo-migrations (6.1.1)
- Installing jinja2 (2.10.3)
- Installing psycopg2-binary (2.8.4)
- Installing python-sql (1.0.0)
- Installing my_package (0.2.0)

[EnvCommandError]
Command ['/Users/thopper/c/poetry-test/env/bin/pip', 'install', '--no-deps', '--cert', '/Users/thopper/cert.pem', '--index-url', 'https://artifactory.example.com/api/pypi/example-pypi/simple', '--extra-index-url', 'https://pypi.org/', 'my_package==0.2.0'] errored with the following return code 1, and output:
Looking in indexes: https://artifactory.example.com/api/pypi/example-pypi/simple, https://pypi.org/
Collecting my_package==0.2.0
Using cached https://artifactory.example.com/api/pypi/example-pypi/my_package/0.2.0/my_package-0.2.0.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
Complete output from command /Users/thopper/c/poetry-test/env/bin/python -m pip install --ignore-installed --no-user --prefix /private/var/folders/mg/9dh5w1r93w3630s4p0y33_c40000gn/T/pip-build-env-y1xpueb9 --no-warn-script-location --no-binary :none: --only-binary :none: -i https://artifactory.example.com/api/pypi/example-pypi/simple --extra-index-url https://pypi.org/ -- setuptools wheel:
Looking in indexes: https://artifactory.example.com/api/pypi/example-pypi/simple, https://pypi.org/
Collecting setuptools
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /api/pypi/example-pypi/simple/setuptools/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /api/pypi/example-pypi/simple/setuptools/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /api/pypi/example-pypi/simple/setuptools/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /api/pypi/example-pypi/simple/setuptools/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)': /api/pypi/example-pypi/simple/setuptools/
Could not fetch URL https://artifactory.example.com/api/pypi/example-pypi/simple/setuptools/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='artifactory.example.com', port=443): Max retries exceeded with url: /api/pypi/example-pypi/simple/setuptools/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),)) - skipping
Could not find a version that satisfies the requirement setuptools (from versions: )
No matching distribution found for setuptools
You are using pip version 18.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

----------------------------------------
Command "/Users/thopper/c/poetry-test/env/bin/python -m pip install --ignore-installed --no-user --prefix /private/var/folders/mg/9dh5w1r93w3630s4p0y33_c40000gn/T/pip-build-env-y1xpueb9 --no-warn-script-location --no-binary :none: --only-binary :none: -i https://artifactory.example.com/api/pypi/example-pypi/simple --extra-index-url https://pypi.org/ -- setuptools wheel" failed with error code 1 in None
You are using pip version 18.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.


Traceback (most recent call last):
File "/Users/thopper/.poetry/lib/poetry/_vendor/py3.6/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/Users/thopper/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/Users/thopper/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/Users/thopper/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/Users/thopper/.poetry/lib/poetry/console/commands/add.py", line 149, in handle
status = installer.run()
File "/Users/thopper/.poetry/lib/poetry/installation/installer.py", line 74, in run
self._do_install(local_repo)
File "/Users/thopper/.poetry/lib/poetry/installation/installer.py", line 286, in _do_install
self._execute(op)
File "/Users/thopper/.poetry/lib/poetry/installation/installer.py", line 302, in _execute
getattr(self, '_execute_{}'.format(method))(operation)
File "/Users/thopper/.poetry/lib/poetry/installation/installer.py", line 327, in _execute_install
self._installer.install(operation.package)
File "/Users/thopper/.poetry/lib/poetry/installation/pip_installer.py", line 97, in install
self.run(*args)
File "/Users/thopper/.poetry/lib/poetry/installation/pip_installer.py", line 123, in run
return self._env.run_pip(*args, **kwargs)
File "/Users/thopper/.poetry/lib/poetry/utils/env.py", line 843, in run_pip
return self._run(cmd, **kwargs)
File "/Users/thopper/.poetry/lib/poetry/utils/env.py", line 1071, in _run
return super(VirtualEnv, self)._run(cmd, **kwargs)
File "/Users/thopper/.poetry/lib/poetry/utils/env.py", line 875, in _run
raise EnvCommandError(e, input=input_)

# Fixed code
def search(self, query):
    results = []

    search = {"q": query}

    response = session().get(self._base_url + "search", params=search)
    content = parse(response.content, namespaceHTMLElements=False)
    for result in content.findall(".//*[@class='package-snippet']"):
        name = result.find("h3/*[@class='package-snippet__name']").text
        version = result.find("h3/*[@class='package-snippet__version']").text

        if not name or not version:
            continue

        description = result.find("p[@class='package-snippet__description']").text
        if not description:
            description = ""

        try:
            result = Package(name, version, description)
            result.description = to_str(description.strip())
            results.append(result)
        except ParseVersionError:
            self._log(
                'Unable to parse version "{}" for the {} package, skipping'.format(
                    version, name
                ),
                level="debug",
            )

    return results