Exemplo n.º 1
0
def check_harness():
    # try to redirect stderr to a file so that the intentional
    # exceptions in the "fail" tests below won't freak out the user
    if os.name == 'posix':
        outstr = '2>&1 > harness_check.out'
    elif os.name == 'nt':
        outstr = '2>1> harness_check.out'
    else:
        # don't know how to redirect stderr here ...
        outstr = '> harness_check.out'
        
    # known "pass" tests
    for good in ['test_pass_1.py','test_pass_2.py','test_pass_3.py']:
        r = os.system('%s %s %s' % (py,good,outstr))
        if r != 0:
            pechof(tout,"****** Harness test failed ******")
            sys.exit(1)

    # known "fail" tests
    print "***************** INGORE EXCEPTIONS BETWEEN THESE LINES *****************"	
    for bad in ['test_fail_exit.py','test_fail_raise_1.py',
                'test_fail_raise_2.py','test_fail_raise_3.py']:
        r = os.system('%s %s %s' % (py,bad,outstr))
        if r == 0:
            pechof(tout,"****** Harness test failed ******")
            sys.exit(1)

    print "***************** INGORE EXCEPTIONS BETWEEN THESE LINES *****************"
    
    unlink('harness_check.out')
Exemplo n.º 2
0
    print "ERROR"
    sys.exit(1)
fh.close()

# method 4 -- StreamWriter is a compressed file
fh = open('aaa','wb')
xml_pickle.dump(f,fh,1)
fh.close()

# check header + contents
fh = open('aaa','rb')
line = fh.read(2)
if line == '\037\213':
    print "OK"
else:
    print "ERROR"
    sys.exit(1) 
    
fh.close()

fh = open('aaa','rb')
g = xml_pickle.load(fh)
if g.a == (1,2,3):
    print "OK"
else:
    print "ERROR"
    sys.exit(1)
fh.close()

funcs.unlink('aaa')
Exemplo n.º 3
0
    sys.exit(1)
fh.close()

## method 4 -- StreamWriter is a compressed file
#fh = open('aaa','wb')
#xml_pickle.dump(f,fh,1)
#fh.close()

## check header + contents
#fh = open('aaa','rb')
#line = fh.read(2)
#if line == '\037\213':
#print "OK"
#else:
#print "ERROR"
#sys.exit(1)

#fh.close()

#fh = open('aaa','rb')
#g = xml_pickle.load(fh)
#if g.a == (1,2,3):
#print "OK"
#else:
#print "ERROR"
#sys.exit(1)
#fh.close()
print('OK')

funcs.unlink('aaa')
Exemplo n.º 4
0
xml_pickle.setParanoia(0)

m = xml_pickle.loads(x)
print m.l, m.d, m.t

# now test dump/load to/from a file

fh = open('aaa', 'w')
pickle.dump(m, fh)
fh.close()

fh = open('bbb', 'w')
xml_pickle.dump(m, fh)
fh.close()
del m

fh = open('aaa', 'r')
g = pickle.load(fh)
fh.close()
print g.l, g.d, g.t
del g

fh = open('bbb', 'r')
g = xml_pickle.load(fh)
fh.close()
print g.l, g.d, g.t
del g

unlink('aaa')
unlink('bbb')
Exemplo n.º 5
0
    f.write(line+'\n')

def pechof(filename,line):
    print line
    if os.path.isfile(filename):
        f = open(filename,'a')
    else:
        f = open(filename,'w')

    f.write(line+'\n')

#tout = 'TESTS.OUT-%s' % os.path.split(py)[-1]
tout = 'TESTS.OUT-%s-%s' % (sys.platform,sys.version.split()[0])

unlink(tout)
touch(tout)

tests = []
for name in string.split(maintests):
    tests.append( 'test_%s.py' % name )

if gnosis.pyconfig.Have_Generators() and \
   gnosis.pyconfig.Have_Module('itertools'):
    tests.append('test_objectify.py')
else:
    pechof(tout,"*** OMITTING test_objectify.py")

if gnosis.pyconfig.IsLegal_BaseClass('unicode'):
    tests.append('test_badstring.py')
else:
Exemplo n.º 6
0
    f.write(line+'\n')

def pechof(filename,line):
    print(line)
    if os.path.isfile(filename):
        f = open(filename,'a')
    else:
        f = open(filename,'w')

    f.write(line+'\n')

#tout = 'TESTS.OUT-%s' % os.path.split(py)[-1]
tout = 'TESTS.OUT-%s-%s' % (sys.platform,sys.version.split()[0])

unlink(tout)
touch(tout)

tests = []
for name in string.split(maintests):
    tests.append( 'test_%s.py' % name )

#if gnosis.pyconfig.Have_Generators() and \
   #gnosis.pyconfig.Have_Module('itertools'):
    #tests.append('test_objectify.py')
#else:
    #pechof(tout,"*** OMITTING test_objectify.py")
    

tests.append('test_subbltin.py')
tests.append('test_slots.py')
Exemplo n.º 7
0
xml_pickle.setParanoia(0)

m = xml_pickle.loads(x)
testfoo(f,m)

# now test dump/load to/from a file

fh = open('aaa','w')
pickle.dump(m,fh)
fh.close()

fh = open('bbb','w')
xml_pickle.dump(m,fh)
fh.close()

fh = open('aaa','r')
g = pickle.load(fh)
fh.close()
testfoo(f,g)

fh = open('bbb','r')
g = xml_pickle.load(fh)
fh.close()
testfoo(f,g)

unlink('aaa')
unlink('bbb')

print "** OK **"