From f03d378014b99436fa0d1fa66041a8df6a26d20c Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Mon, 20 Jul 2020 12:33:15 +0100
Subject: [PATCH] TEST: Test abspath

---
 tests/test_scripts/test_fsl_abspath.py | 45 ++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 tests/test_scripts/test_fsl_abspath.py

diff --git a/tests/test_scripts/test_fsl_abspath.py b/tests/test_scripts/test_fsl_abspath.py
new file mode 100644
index 000000000..165712897
--- /dev/null
+++ b/tests/test_scripts/test_fsl_abspath.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# test_fsl_abspath.py -
+#
+# Author: Paul McCarthy <pauldmccarthy@gmail.com>
+#
+
+
+import os.path as op
+
+import fsl.scripts.fsl_abspath as fsl_abspath
+
+from tests import tempdir, CaptureStdout
+
+
+def test_usage():
+    assert fsl_abspath.main([]) != 0
+
+
+def test_fsl_abspath():
+
+    # fsl_abspath just calls os.path.realpath
+
+    with tempdir() as td:
+
+        oneup = op.dirname(td)
+
+        # (input, expected)
+        tests = [
+            ('file',    f'{td}/file'),
+            ('./file',  f'{td}/file'),
+            ('../file', f'{oneup}/file'),
+
+            ('/file',         '/file'),
+            ('/one/two/file', '/one/two/file'),
+        ]
+
+        for input, expected in tests:
+            cap = CaptureStdout()
+
+            with cap:
+                ret = fsl_abspath.main([input])
+
+            assert ret == 0
+            assert cap.stdout.strip() == expected
-- 
GitLab