forked from pool/python-straight-plugin
42 lines
1.4 KiB
Diff
42 lines
1.4 KiB
Diff
|
From fbe969310abfb0294313372da20a4b7dc99ea0a8 Mon Sep 17 00:00:00 2001
|
||
|
From: Lars van de Kerkhof <lars@permanentmarkers.nl>
|
||
|
Date: Thu, 28 Jun 2018 15:40:39 +0200
|
||
|
Subject: [PATCH 1/3] Fixes pip with no plugins installed.
|
||
|
|
||
|
---
|
||
|
straight/plugin/manager.py | 2 +-
|
||
|
tests.py | 5 ++++-
|
||
|
2 files changed, 5 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/straight/plugin/manager.py b/straight/plugin/manager.py
|
||
|
index 2a426ea..fadb397 100644
|
||
|
--- a/straight/plugin/manager.py
|
||
|
+++ b/straight/plugin/manager.py
|
||
|
@@ -50,7 +50,7 @@ def pipe(self, methodname, first_arg, *args, **kwargs):
|
||
|
|
||
|
Useful to utilize plugins as sets of filters.
|
||
|
"""
|
||
|
-
|
||
|
+ r = first_arg
|
||
|
for plugin in self._plugins:
|
||
|
method = getattr(plugin, methodname, None)
|
||
|
if method is None:
|
||
|
diff --git a/tests.py b/tests.py
|
||
|
index 56b104f..6fe8f68 100755
|
||
|
--- a/tests.py
|
||
|
+++ b/tests.py
|
||
|
@@ -257,9 +257,12 @@ def plus_one(x):
|
||
|
return x + 1
|
||
|
self.m._plugins[0].x.side_effect = plus_one
|
||
|
self.m._plugins[1].x.side_effect = plus_one
|
||
|
-
|
||
|
self.assertEqual(3, self.m.pipe('x', 1))
|
||
|
|
||
|
+ def test_pipe_no_plugins_found(self):
|
||
|
+ no_plugins = manager.PluginManager([])
|
||
|
+ self.assertEqual(1, no_plugins.pipe('x', 1))
|
||
|
+
|
||
|
def test_call(self):
|
||
|
results = self.m.call('x', 1)
|
||
|
self.assertTrue(self.m._plugins[0].called_with('a'))
|