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/sasinvariant/test/utest_use_cases.py

    rb09095a r0675e6b  
    44""" 
    55#TODO: there's no test for smeared extrapolation 
     6 
     7import os.path 
    68import unittest 
    79from sas.sascalc.dataloader.loader import  Loader 
     
    911 
    1012 
     13def find(filename): 
     14    return os.path.join(os.path.dirname(__file__), filename) 
     15 
     16 
    1117class Data1D: 
    1218    pass 
     
    1824    """ 
    1925    def setUp(self): 
    20         self.data_list = Loader().load("linefittest.txt") 
     26        self.data_list = Loader().load(find("linefittest.txt")) 
    2127        self.data = self.data_list[0] 
    2228 
     
    5763    """ 
    5864    def setUp(self): 
    59         self.data_list = Loader().load("linefittest_no_weight.txt") 
     65        self.data_list = Loader().load(find("linefittest_no_weight.txt")) 
    6066        self.data = self.data_list[0] 
    6167 
     
    96102    """ 
    97103    def setUp(self): 
    98         self.data_list = Loader().load("PolySpheres.txt") 
     104        self.data_list = Loader().load(find("PolySpheres.txt")) 
    99105        self.data = self.data_list[0] 
    100106 
     
    278284    def setUp(self): 
    279285        # data with smear info 
    280         list = Loader().load("latex_smeared.xml") 
     286        list = Loader().load(find("latex_smeared.xml")) 
    281287        self.data_q_smear = list[0] 
    282288 
Note: See TracChangeset for help on using the changeset viewer.