Skip to content

Commit

Permalink
Add some unittests for Plugin Client.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaverde committed Mar 17, 2017
1 parent 0f4d6cf commit e90fb04
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
7 changes: 4 additions & 3 deletions spyder/utils/introspection/plugin_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run(self):
# Set up environment variables.
processEnvironment = QProcessEnvironment()
env = self.process.systemEnvironment()
if (self.env and 'PYTHONPATH' not in self.env) or DEV:
if (self.env and 'PYTHONPATH' not in self.env) or self.env is None:
python_path = osp.dirname(get_module_path('spyder'))
# Add the libs to the python path.
for lib in self.libs:
Expand All @@ -94,8 +94,9 @@ def run(self):
try:
python_path = osp.pathsep.join([python_path] +
self.extra_path)
except Exception:
pass
except Exception as e:
debug_print("Error when adding extra_path to plugin env")
debug_print(e)
env.append("PYTHONPATH=%s" % python_path)
if self.env:
env.update(self.env)
Expand Down
39 changes: 39 additions & 0 deletions spyder/utils/introspection/tests/test_plugin_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
#
"""Tests for plugin_client.py."""

# Test library imports
import pytest

# Local imports
from spyder.utils.introspection.plugin_client import PluginClient
from spyder.utils.introspection.manager import PLUGINS


@pytest.mark.parametrize("plugin_name", PLUGINS)
def test_plugin_client(qtbot, plugin_name):
"""Test creation of the diferent plugin clients."""
plugin = PluginClient(plugin_name=plugin_name)

assert plugin


@pytest.mark.parametrize("plugin_name", PLUGINS)
def test_plugin_client_extra_path(qtbot, plugin_name):
"""Test adding of extra path.
Extra path is used for adding spyder_path to plugin clients.
"""
extra_path = '/some/dummy/path'

plugin = PluginClient(plugin_name=plugin_name, extra_path=[extra_path])
plugin.run()
python_path = plugin.process.processEnvironment().value('PYTHONPATH')
assert extra_path in python_path.split(':')


if __name__ == "__main__":
pytest.main()

0 comments on commit e90fb04

Please sign in to comment.