summaryrefslogtreecommitdiff
path: root/tests/common/pathname.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/pathname.py')
-rw-r--r--tests/common/pathname.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/common/pathname.py b/tests/common/pathname.py
index 3692434..00a084b 100644
--- a/tests/common/pathname.py
+++ b/tests/common/pathname.py
@@ -1,21 +1,15 @@
-#!/usr/bin/python3-dbg
-# -*- coding: utf-8 -*-
-
-
-# Tests minimalistes pour valider la construction de chemins relatifs et absolus.
-
from chrysacase import ChrysalideTestCase
from pychrysalide.common import pathname
-class TestPathNames(ChrysalideTestCase):
- """TestCase for common.pathname.build*"""
+class TestPathnames(ChrysalideTestCase):
+ """TestCase for common.pathname*"""
@classmethod
def setUpClass(cls):
- super(TestPathNames, cls).setUpClass()
+ super(TestPathnames, cls).setUpClass()
cls._tests = [
{
@@ -93,3 +87,24 @@ class TestPathNames(ChrysalideTestCase):
with self.assertRaisesRegex(Exception, 'Relative path is too deep.'):
got = build_absolute('/a/b', '../../c')
+
+
+ def testPathnameConstructor(self):
+ """Check that no constructor is available for the pathname class."""
+
+ with self.assertRaisesRegex(NotImplementedError, 'Chrysalide does not allow building this kind of object from Python'):
+
+ instance = pathname()
+
+
+ def testPathnameSamples(self):
+ """Play with some path samples."""
+
+ filename = pathname.build_absolute_filename('/tmp/deep', '../myfile')
+ self.assertEqual(filename, '/myfile')
+
+ filename = pathname.build_absolute_filename('/tmp/deep/', '../myfile')
+ self.assertEqual(filename, '/tmp/myfile')
+
+ filename = pathname.build_relative_filename('/tmp/deep', '/myfile')
+ self.assertEqual(filename, '../myfile')