Ignore:
Timestamp:
Dec 5, 2017 10:31:07 AM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
5bb05a4
Parents:
3053a4a
git-author:
Stuart Prescott <llimeht@…> (12/05/17 10:31:07)
git-committer:
Paul Kienzle <pkienzle@…> (12/05/17 10:31:07)
Message:

Make tests work from any directory and functional without special runner script (#124)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/pr_inversion/test/utest_invertor.py

    rcb62bd5 rf53d684  
    1010 
    1111import os 
     12import os.path 
    1213import unittest 
    1314import math 
    1415import numpy 
    1516from sas.sascalc.pr.invertor import Invertor 
     17 
     18 
     19def find(filename): 
     20    return os.path.join(os.path.dirname(__file__), filename) 
    1621 
    1722 
     
    2833            self.x_in[i] = 1.0*(i+1) 
    2934        
    30         x, y, err = load("sphere_80.txt") 
     35        x, y, err = load(find("sphere_80.txt")) 
    3136 
    3237        # Choose the right d_max... 
     
    192197            Test an inversion for which we know the answer 
    193198        """ 
    194         x, y, err = load("sphere_80.txt") 
     199        x, y, err = load(find("sphere_80.txt")) 
    195200 
    196201        # Choose the right d_max... 
     
    247252            Test an inversion for which we know the answer 
    248253        """ 
    249         x, y, err = load("sphere_80.txt") 
     254        x, y, err = load(find("sphere_80.txt")) 
    250255 
    251256        # Choose the right d_max... 
     
    312317            Test error condition where a point has q=0 
    313318        """ 
    314         x, y, err = load("sphere_80.txt") 
     319        x, y, err = load(find("sphere_80.txt")) 
    315320        x[0] = 0.0 
    316321         
     
    329334            Test error condition where a point has q<0 
    330335        """ 
    331         x, y, err = load("sphere_80.txt") 
     336        x, y, err = load(find("sphere_80.txt")) 
    332337        x[0] = -0.2 
    333338         
     
    353358            Test error condition where a point has q<0 
    354359        """ 
    355         x, y, err = load("sphere_80.txt") 
     360        x, y, err = load(find("sphere_80.txt")) 
    356361        y[0] = 0.0 
    357362         
     
    374379         
    375380    def no_test_time(self): 
    376         x, y, err = load("sphere_80.txt") 
     381        x, y, err = load(find("sphere_80.txt")) 
    377382 
    378383        # Choose the right d_max... 
     
    406411         
    407412    def test_save(self): 
    408         x, y, err = load("sphere_80.txt") 
     413        x, y, err = load(find("sphere_80.txt")) 
    409414 
    410415        # Choose the right d_max... 
     
    464469            Test an inversion for which we know the answer 
    465470        """ 
    466         x, y, err = load("data_error_1.txt") 
     471        x, y, err = load(find("data_error_1.txt")) 
    467472 
    468473        # Choose the right d_max... 
     
    482487            Have zero as an error should raise an exception 
    483488        """ 
    484         x, y, err = load("data_error_2.txt") 
     489        x, y, err = load(find("data_error_2.txt")) 
    485490 
    486491        # Set data 
     
    495500            Test an inversion for which we know the answer 
    496501        """ 
    497         x, y, err = load("data_error_1.txt") 
     502        x, y, err = load(find("data_error_1.txt")) 
    498503 
    499504        # Set data 
     
    511516            An exception should be raised. 
    512517        """ 
    513         x, y, err = load("data_error_3.txt") 
     518        x, y, err = load(find("data_error_3.txt")) 
    514519 
    515520        # Set data 
     
    521526            Should not complain or crash. 
    522527        """ 
    523         x, y, err = load("data_error_4.txt") 
     528        x, y, err = load(find("data_error_4.txt")) 
    524529 
    525530        # Set data 
     
    535540            Makes not sense, but should not complain or crash. 
    536541        """ 
    537         x, y, err = load("data_error_5.txt") 
     542        x, y, err = load(find("data_error_5.txt")) 
    538543 
    539544        # Set data 
     
    549554            Makes not sense, but should not complain or crash. 
    550555        """ 
    551         x, y, err = load("data_error_6.txt") 
     556        x, y, err = load(find("data_error_6.txt")) 
    552557 
    553558        # Set data 
Note: See TracChangeset for help on using the changeset viewer.