Ignore:
Timestamp:
Nov 4, 2017 9:21:04 AM (7 years ago)
Author:
Stuart Prescott <stuart@…>
Parents:
cb11a25
git-author:
Stuart Prescott <stuart@…> (11/02/17 02:50:18)
git-committer:
Stuart Prescott <stuart@…> (11/04/17 09:21:04)
Message:

Fix tests to find resources without changing dir

Test resources are in the same directory (or a child directory) of the test
code so the code can locate the resources itself rather than relying on the
tests being run from a certain location. This allows the tests to be used to
test the installed code rather than the current checkout and also allows
automated test discovery with tools like py.test to be used, running all
tests at once without a runner.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/fileconverter/test/utest_nxcansas_writer.py

    rc16ffe7 r0675e6b  
    33 
    44import os 
     5import os.path 
    56import unittest 
    67import warnings 
    78 
    89warnings.simplefilter("ignore") 
     10 
     11 
     12def find(filename): 
     13    return os.path.join(os.path.dirname(__file__), filename) 
     14 
    915 
    1016class nxcansas_writer(unittest.TestCase): 
     
    1319        self.loader = Loader() 
    1420        self.writer = NXcanSASWriter() 
    15         self.read_file_1d = "cansas1d.xml" 
    16         self.write_file_1d = "export1d.h5" 
    17         self.read_file_2d = "exp18_14_igor_2dqxqy.dat" 
    18         self.write_file_2d = "export2d.h5" 
     21        self.read_file_1d = find("cansas1d.xml") 
     22        self.write_file_1d = find("export1d.h5") 
     23        self.read_file_2d = find("exp18_14_igor_2dqxqy.dat") 
     24        self.write_file_2d = find("export2d.h5") 
    1925 
    2026        self.data_1d = self.loader.load(self.read_file_1d)[0] 
Note: See TracChangeset for help on using the changeset viewer.