[Piglit] [PATCH 3/7] framework/grouptools: fix commonprefix with empty value
Dylan Baker
baker.dylan.c at gmail.com
Wed Sep 2 14:18:22 PDT 2015
---
framework/grouptools.py | 2 ++
framework/tests/grouptools_tests.py | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/framework/grouptools.py b/framework/grouptools.py
index 81e6091..d6749d6 100644
--- a/framework/grouptools.py
+++ b/framework/grouptools.py
@@ -81,6 +81,8 @@ def commonprefix(args):
"""Given a list of groups, returns the longest common leading component."""
if len(args) == 1:
return args
+ elif any(e == '' for e in args):
+ return ''
common = []
diff --git a/framework/tests/grouptools_tests.py b/framework/tests/grouptools_tests.py
index e41ad2c..e3b4ee0 100644
--- a/framework/tests/grouptools_tests.py
+++ b/framework/tests/grouptools_tests.py
@@ -99,3 +99,11 @@ def test_from_path_nt():
def test_from_path_dot():
"""grouptools.from_path: should convert '.' into ''."""
nt.assert_equal(grouptools.from_path('.'), '')
+
+
+def test_commonprefix_empty():
+ """grouptools.commonprefix: handles an empty value"""
+ expected = ''
+ value = grouptools.commonprefix((grouptools.join('foo', 'bar'), ''))
+
+ nt.eq_(expected, value)
--
2.5.1
More information about the Piglit
mailing list