summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/common/fnv1a.py13
-rw-r--r--tests/common/pathname.py30
2 files changed, 11 insertions, 32 deletions
diff --git a/tests/common/fnv1a.py b/tests/common/fnv1a.py
index 2013afa..3bb7c32 100644
--- a/tests/common/fnv1a.py
+++ b/tests/common/fnv1a.py
@@ -4,22 +4,15 @@ from pychrysalide.common import fnv1a
class TestFnv1a(ChrysalideTestCase):
- """TestCase for common.fnv1a*"""
-
- def testFnv1aConstructor(self):
- """Check that no constructor is available for the fnv1a class."""
-
- with self.assertRaisesRegex(NotImplementedError, 'Chrysalide does not allow building this kind of object from Python'):
- instance = fnv1a()
-
+ """TestCase for common FNV-1a hashing features."""
def testFnv1aSamples(self):
"""Compute some Fnv1a hashs."""
# Test cases from http://isthe.com/chongo/src/fnv/test_fnv.c
- val = fnv1a.hash('')
+ val = fnv1a('')
self.assertEqual(val, 0xcbf29ce484222325)
- val = fnv1a.hash('chongo was here!\n')
+ val = fnv1a('chongo was here!\n')
self.assertEqual(val, 0x46810940eff5f915)
diff --git a/tests/common/pathname.py b/tests/common/pathname.py
index 00a084b..23ca2b0 100644
--- a/tests/common/pathname.py
+++ b/tests/common/pathname.py
@@ -1,10 +1,10 @@
from chrysacase import ChrysalideTestCase
-from pychrysalide.common import pathname
+from pychrysalide.common import build_relative_filename, build_absolute_filename
class TestPathnames(ChrysalideTestCase):
- """TestCase for common.pathname*"""
+ """TestCase for common pathname features."""
@classmethod
def setUpClass(cls):
@@ -58,11 +58,9 @@ class TestPathnames(ChrysalideTestCase):
def testBuildingRelative(self):
"""Build valid relative paths."""
- build_relative = pathname.build_relative_filename
-
for tst in self._tests:
- got = build_relative(tst['ref'], tst['target'])
+ got = build_relative_filename(tst['ref'], tst['target'])
self.assertEqual(got, tst['relative'])
@@ -70,11 +68,9 @@ class TestPathnames(ChrysalideTestCase):
def testBuildingAbsolute(self):
"""Build valid absolute paths."""
- build_absolute = pathname.build_absolute_filename
-
for tst in self._tests:
- got = build_absolute(tst['ref'], tst['relative'])
+ got = build_absolute_filename(tst['ref'], tst['relative'])
self.assertEqual(got, tst['target'])
@@ -82,29 +78,19 @@ class TestPathnames(ChrysalideTestCase):
def testBuildingWrongAbsolute(self):
"""Build invalid absolute paths."""
- build_absolute = pathname.build_absolute_filename
-
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()
+ got = build_absolute_filename('/a/b', '../../c')
def testPathnameSamples(self):
"""Play with some path samples."""
- filename = pathname.build_absolute_filename('/tmp/deep', '../myfile')
+ filename = build_absolute_filename('/tmp/deep', '../myfile')
self.assertEqual(filename, '/myfile')
- filename = pathname.build_absolute_filename('/tmp/deep/', '../myfile')
+ filename = build_absolute_filename('/tmp/deep/', '../myfile')
self.assertEqual(filename, '/tmp/myfile')
- filename = pathname.build_relative_filename('/tmp/deep', '/myfile')
+ filename = build_relative_filename('/tmp/deep', '/myfile')
self.assertEqual(filename, '../myfile')