summaryrefslogtreecommitdiff
path: root/scipy/weave/tests/test_standard_array_spec.py
blob: 5ce5667b246e676a4efff3eee4c93fa3dcbe1071 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import unittest
from scipy_base.numerix import *
from scipy_base.numerix import RandomArray
import time

from scipy_test.testing import *
set_package_path()
from weave import standard_array_spec
restore_path()

def remove_whitespace(in_str):
    import string
    out = string.replace(in_str," ","")
    out = string.replace(out,"\t","")
    out = string.replace(out,"\n","")
    return out
    
def print_assert_equal(test_string,actual,desired):
    """this should probably be in scipy_test.testing
    """
    import pprint
    try:
        assert(actual == desired)
    except AssertionError:
        import cStringIO
        msg = cStringIO.StringIO()
        msg.write(test_string)
        msg.write(' failed\nACTUAL: \n')
        pprint.pprint(actual,msg)
        msg.write('DESIRED: \n')
        pprint.pprint(desired,msg)
        raise AssertionError, msg.getvalue()

class test_array_converter(unittest.TestCase):    
    def check_type_match_string(self):
        s = standard_array_spec.array_converter()
        assert( not s.type_match('string') )
    def check_type_match_int(self):
        s = standard_array_spec.array_converter()        
        assert(not s.type_match(5))
    def check_type_match_array(self):
        s = standard_array_spec.array_converter()        
        assert(s.type_match(arange(4)))

if __name__ == "__main__":
    ScipyTest('weave.standard_array_spec').run()