summaryrefslogtreecommitdiff
path: root/morphlib/util_tests.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-06-17 16:36:07 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-07-10 13:50:00 +0000
commit3dc83847b8f17793bdab5e978d13d394b48987b0 (patch)
treea67c54b99b7e822ab7f49df3c9df2199435f21ff /morphlib/util_tests.py
parentae007688d8f1f57b138dafffdfc3683aa7c7730f (diff)
downloadmorph-3dc83847b8f17793bdab5e978d13d394b48987b0.tar.gz
Use exact filenames to refer to morphology files
Rather than repeatedly stripping and appending an optional .morph extension morphology names, instead always use the file path of the morphology relative to the definitions repository. This is an inversion of the previous logic, which would strip the .morph extension and use the "name" internally. The exception to this rule of always using the filename, is that `morph edit CHUNK` uses the name of the morphology as-defined in the stratum. This is based off Adam Coldrick's inital patch, but this version will allow the old style of providing the "name" by converting it into a path if it does not have either a / or a . in it. An unfortunate consequence of this change is that the show-dependencies command's output changed, so the test needed updating.
Diffstat (limited to 'morphlib/util_tests.py')
-rw-r--r--morphlib/util_tests.py29
1 files changed, 11 insertions, 18 deletions
diff --git a/morphlib/util_tests.py b/morphlib/util_tests.py
index 5a8ae797..715892b6 100644
--- a/morphlib/util_tests.py
+++ b/morphlib/util_tests.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2013 Codethink Limited
+# Copyright (C) 2011-2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -38,26 +38,19 @@ class IndentTests(unittest.TestCase):
' foo\n bar')
-class StripMorphExtensionTests(unittest.TestCase):
+class SanitiseMorphologyPathTests(unittest.TestCase):
- def test_raises_error_when_string_starts_with_period(self):
- with self.assertRaises(morphlib.Error):
- morphlib.util.strip_morph_extension('.morph')
-
- def test_strips_morph_extension_from_string(self):
- self.assertEqual(morphlib.util.strip_morph_extension('a.morph'), 'a')
-
- def test_returns_morph_when_not_given_as_extension(self):
- self.assertEqual(morphlib.util.strip_morph_extension('morph'), 'morph')
-
- def test_strips_extension_only_once_from_string(self):
- self.assertEqual(morphlib.util.strip_morph_extension('a.morph.morph'),
+ def test_appends_morph_to_string(self):
+ self.assertEqual(morphlib.util.sanitise_morphology_path('a'),
'a.morph')
- def test_returns_input_without_modification_if_no_extension(self):
- self.assertEqual(
- morphlib.util.strip_morph_extension('completely not a path'),
- 'completely not a path')
+ def test_returns_morph_when_given_a_filename(self):
+ self.assertEqual(morphlib.util.sanitise_morphology_path('a.morph'),
+ 'a.morph')
+
+ def test_returns_morph_when_given_a_path(self):
+ self.assertEqual('stratum/a.morph',
+ morphlib.util.sanitise_morphology_path('stratum/a.morph'))
class MakeConcurrencyTests(unittest.TestCase):