Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-09-24 13:49:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-09-24 13:52:58 +0300
commitfc6f4c11aebfb89adb08c75ded295e80e375b0b8 (patch)
treed55144da6c6a44ea928d6c5a805f85374d32e0bf /tests/python/bl_pyapi_bpy_path.py
parent81f64312d29260fded00da75ddb0f3da730585b0 (diff)
Add test scripts to ctest & rename
Diffstat (limited to 'tests/python/bl_pyapi_bpy_path.py')
-rw-r--r--tests/python/bl_pyapi_bpy_path.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/python/bl_pyapi_bpy_path.py b/tests/python/bl_pyapi_bpy_path.py
new file mode 100644
index 00000000000..2d6019fbb07
--- /dev/null
+++ b/tests/python/bl_pyapi_bpy_path.py
@@ -0,0 +1,41 @@
+# Apache License, Version 2.0
+
+# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_bpy_path.py -- --verbose
+import unittest
+
+
+class TestBpyPath(unittest.TestCase):
+ def test_ensure_ext(self):
+ from bpy.path import ensure_ext
+
+ # Should work with both strings and bytes.
+ self.assertEqual(ensure_ext('demo', '.blend'), 'demo.blend')
+ self.assertEqual(ensure_ext(b'demo', b'.blend'), b'demo.blend')
+
+ # Test different cases.
+ self.assertEqual(ensure_ext('demo.blend', '.blend'), 'demo.blend')
+ self.assertEqual(ensure_ext('demo.BLEND', '.blend'), 'demo.BLEND')
+ self.assertEqual(ensure_ext('demo.blend', '.BLEND'), 'demo.blend')
+
+ # Test empty extensions, compound extensions etc.
+ self.assertEqual(ensure_ext('demo', 'blend'), 'demoblend')
+ self.assertEqual(ensure_ext('demo', ''), 'demo')
+ self.assertEqual(ensure_ext('demo', '.json.gz'), 'demo.json.gz')
+ self.assertEqual(ensure_ext('demo.json.gz', '.json.gz'), 'demo.json.gz')
+ self.assertEqual(ensure_ext('demo.json', '.json.gz'), 'demo.json.json.gz')
+ self.assertEqual(ensure_ext('', ''), '')
+ self.assertEqual(ensure_ext('', '.blend'), '.blend')
+
+ # Test case-sensitive behaviour.
+ self.assertEqual(ensure_ext('demo', '.blend', True), 'demo.blend')
+ self.assertEqual(ensure_ext('demo.BLEND', '.blend', True), 'demo.BLEND.blend')
+ self.assertEqual(ensure_ext('demo', 'Blend', True), 'demoBlend')
+ self.assertEqual(ensure_ext('demoBlend', 'blend', True), 'demoBlendblend')
+ self.assertEqual(ensure_ext('demo', '', True), 'demo')
+
+
+if __name__ == '__main__':
+ import sys
+
+ sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
+ unittest.main()