]> Creatis software - gdcm.git/commitdiff
Benoit Regrain : Modify the rules for checking the paths
authorjpr <jpr>
Wed, 5 Nov 2003 14:07:31 +0000 (14:07 +0000)
committerjpr <jpr>
Wed, 5 Nov 2003 14:07:31 +0000 (14:07 +0000)
                 : Explicit error messages
Jean-Pierre Roux : new files names for checking

gdcmPython/__init__.py
gdcmPython/testSuite.py

index 26de4736dda7eb8520978e990b586ebd7422470e..dcad484cb23efa8365c080bd12deb841451ba881 100644 (file)
@@ -1,6 +1,6 @@
 import os, sys
 
-def BuildInstallOrPreinstallPath(DirName, FileName):
+def BuildInstallOrPreinstallPath(DirName, FileName = None):
    # Builds a path to the DirName directory. This should work both when:
    # - the package is properly installed in which case DirName is a subdir
    #   of the package,
@@ -10,13 +10,23 @@ def BuildInstallOrPreinstallPath(DirName, FileName):
    # In both cases we need to express the full path to DirName relatively
    # to the path to this __init__.py. For this we rely on __path__ variable.
    # In order to make sure we got the correct Path, we check for the
-   # existence of FileName.
+   # existence of FileName if it is setted otherwise for the existence of the
+   # DirName.
    InstallModePath = os.path.join(__path__[0], DirName + "/")
-   if os.path.isfile(os.path.join(InstallModePath, FileName)):
-      return InstallModePath
+   if(FileName):
+      if os.path.isfile(os.path.join(InstallModePath, FileName)):
+         return InstallModePath
+   else:
+      if os.path.isdir(InstallModePath):
+         return InstallModePath
+
    PreInstallModePath = os.path.join(__path__[0], "..", DirName + "/")
-   if os.path.isfile(os.path.join(PreInstallModePath, FileName)):
-      return PreInstallModePath
+   if(FileName):
+      if os.path.isfile(os.path.join(PreInstallModePath, FileName)):
+         return PreInstallModePath
+   else:
+      if os.path.isdir(PreInstallModePath):
+         return PreInstallModePath
    return None
 
 ### Setup the path to the dictionaries. WARNING: this needs to be done
@@ -45,7 +55,7 @@ if not GDCM_DATA_PATH:
    print "GDCM_DATA_PATH is not setup properly: unfound Test directory"
 
 ### Set up the path to the data images of the test suite.
-GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData", "test.acr")
+GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData")
 
 ### Import the swig generated shadow classes.
 try:
index ff72e39e7dcb843f7f834cdf270ac81a65cada8b..d33cc3cce1f75b3fefd3d888a6e830850315c25c 100644 (file)
@@ -1,5 +1,6 @@
 import unittest
 import os
+from gdcmPython import *
 from vtkgdcmPython import *
 
 class gdcmTestCase(unittest.TestCase):
@@ -486,7 +487,7 @@ class gdcmTestCase(unittest.TestCase):
          #         at 9f8 : fragment length 212866 x(00033f82)
          # at 3497e : ItemTag  b00c,0eb6 (should be fffe,e000 or fffe,e0dd):
  
-      ["gdcm-JPEG-LossLess3b.dcm",
+      ["gdcm-JPEG-LossLessThoravision.dcm",
          # Interest: - Jpeg compression [Lossless, hierar., first-order
          #             pred. 14, Select. Val. 1]
          #           - encoding is sligthly different from LossLess3a.dcm ???
@@ -542,13 +543,24 @@ class gdcmTestCase(unittest.TestCase):
           ("Wrong signature for file %s (got %s, shoud be %s)"
            % (SourceFileName, ComputeSign, Sign)) )
       os.unlink(TargetFileName)
-
+      
 if __name__ == '__main__':
    if not GDCM_TEST_DATA_PATH:
-      print "GDCM_TEST_DATA_PATH is not setup properly. This test suite"
-      print "   requires that some Dicom reference files be installed."
+      print "GDCM_TEST_DATA_PATH (internal variable) is not setup properly."
+      print "   This test suite requires that some Dicom reference files be "
+      print "   installed."
       print "   For further details on installation of gdcmData, please"
       print "   refer to the developper's section of page "
       print "       http://www.creatis.insa-lyon.fr/Public/Gdcm"
-   unittest.main()
+      print ""
+      print "gdcmData directory (used in the test suite) must be placed in"
+      print "the gdcm directory. The gdcm tree must be :"
+      print "   gdcm"
+      print "    |____Dicts"
+      print "    |____Doc"
+      print "    |____gdcmData      (not in gdcm by default)"
+      print "    |____gdcmPython"
+      print "    |____Test"
+   else:
+      unittest.main()