From 72f037649fd427c5b52fdce8ebcb13f5fe79eed2 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Mon, 28 Jan 2019 21:33:19 +0000
Subject: [PATCH] TEST: Unit test for commonBase

---
 tests/test_fsl_utils_path.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tests/test_fsl_utils_path.py b/tests/test_fsl_utils_path.py
index 0820f4ed6..f5e798377 100644
--- a/tests/test_fsl_utils_path.py
+++ b/tests/test_fsl_utils_path.py
@@ -1356,3 +1356,32 @@ def test_uniquePrefix():
 
     finally:
         shutil.rmtree(workdir)
+
+
+def test_commonBase():
+
+    tests = [
+        ('/',
+         ['/a/b/c',
+          '/d/e',
+          '/f/g/h/i']),
+        ('/a',
+         ['/a/b/c',
+          '/a/d/e/f/g',
+          '/a/d/h/g/h/i']),
+        ('a',
+         ['a/b/c/d',
+          'a/e/f/g/h',
+          'a/i/j/k/'])
+    ]
+    for exp, paths in tests:
+        assert fslpath.commonBase(paths) == exp
+
+    failtests = [
+        ['a/b/c', 'd/e/f'],
+        ['/a/b/c', 'd/e/f'],
+        ['a', 'b/c/d']]
+
+    for ft in failtests:
+        with pytest.raises(fslpath.PathError):
+            fslpath.commonBase(ft)
-- 
GitLab