Changeset d083cc


Ignore:
Timestamp:
Jan 24, 2024, 12:09:57 AM (21 months ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
5a479d
Parents:
6dde30
git-author:
Frederik Heber <frederik.heber@…> (01/24/24 00:09:17)
git-committer:
Frederik Heber <frederik.heber@…> (01/24/24 00:09:57)
Message:

Python3: Test/Python changed.

  • print -> print()
Location:
tests/Python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tests/Python/AllActions/moltest.py

    r6dde30 rd083cc  
    2727              key, value = line.split('\t', 1)
    2828            except ValueError:
    29               print "line needs two values, tab-separated: "+line
     29              print("line needs two values, tab-separated: "+line)
    3030              sys.exit(1)
    3131            value = value[1:-2] # quotes entfernen
     
    4646           
    4747            if not param in Defaults:
    48                 print 'Fehlender Defaultwert:', param
     48                print('Fehlender Defaultwert:', param)
    4949       
    5050        # direkt substituieren, oder erst beim aufruf?
     
    5959params = ParseParameters(doc)
    6060
    61 print '--BEGIN-- %s mit %s --------' % (cmd, params)
     61print('--BEGIN-- %s mit %s --------' % (cmd, params))
    6262   
    6363# write command to file
     
    6666output.close()
    6767# call python externally on this file and catch retcode
    68 p = subprocess.Popen(["python", "test.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     68p = subprocess.Popen(["python3", "test.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    6969stdout, stderr = p.communicate()
    70 print ' --- STDOUT ---'
    71 print ' %s ' % (stdout)
    72 print ' --- STDERR ---'
    73 print ' %s ' % (stderr)
     70print(' --- STDOUT ---')
     71print(' %s ' % (stdout))
     72print(' --- STDERR ---')
     73print(' %s ' % (stderr))
    7474retcode = p.returncode
    7575if retcode == 134 or retcode == 0:
    76   print ' ---- ok ----'
     76  print(' ---- ok ----')
    7777else:
    78   print ' -- FAILED with %s --' % (retcode)
     78  print(' -- FAILED with %s --' % (retcode))
    7979#  if retcode == 1:
    8080#    sys.exit(1)
    8181#exec('mol.%s(*params)' % cmd)
    8282
    83 print '---END--- %s mit %s --------' % (cmd, params)
     83print('---END--- %s mit %s --------' % (cmd, params))
    8484
    8585sys.exit(0)
  • tests/Python/AllActions/moltest_check.py

    r6dde30 rd083cc  
    1414              key, value = line.split('\t', 1)
    1515            except ValueError:
    16               print "line needs two values, tab-separated: "+line
     16              print("line needs two values, tab-separated: "+line)
    1717              sys.exit(1)
    1818            value = value[1:-2] # remove quotes
     
    3131           
    3232            if not param in Defaults:
    33                 print >> sys.stderr, param # write missing default value to stderr
     33                print(param, file=sys.stderr) # write missing default value to stderr
    3434                result = 1
    3535
     
    3939
    4040for cmd in cmds:
    41     print "Checking on %s" % cmd
     41    print("Checking on %s" % cmd)
    4242    doc = eval('mol.%s.__doc__' % cmd)
    4343    if CheckParameters(doc) == 1:
  • tests/Python/AllActions/testsuite-python-allactions.at

    r6dde30 rd083cc  
    2323AT_DATA([test.py], [
    2424import pyMoleCuilder as mol
    25 print mol.ThisCommandIsNotPresent()
     25print(mol.ThisCommandIsNotPresent())
    2626])
    2727AT_CHECK([../../run test.py], 1, [ignore], [stderr])
    28 AT_CHECK([fgrep "object has no attribute" stderr], 0, [ignore], [ignore])
     28AT_CHECK([fgrep "has no attribute" stderr], 0, [ignore], [ignore])
    2929AT_CHECK([../../run ${abs_top_srcdir}/tests/Python/AllActions/listcmds.py], 0, [stdout], [ignore])
    3030AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/Python/AllActions/options.dat .],  0, [ignore], [ignore])
  • tests/Python/ForceAnnealing/pre/ising_model_chain.py

    r6dde30 rd083cc  
    88
    99if len(sys.argv) < 5:
    10         print 'Usage: '+sys.argv[0]+' <input> <path> <steps> <no_atoms> <use bondgraph>'
     10        print('Usage: '+sys.argv[0]+' <input> <path> <steps> <no_atoms> <use bondgraph>')
    1111        sys.exit(1)
    1212
     
    2121# creating input file
    2222atomstart=7.6-1.6*math.floor(no_atoms/2)
    23 print "Creating "+inputfile
     23print("Creating "+inputfile)
    2424with open(inputfile, 'w') as f:
    2525        f.write("# ATOMDATA\ttype\tId\tx=3\tu=3\tF=3\tneighbors=4\n")
     
    3636                        f.write("C\t%d\t%lg\t10\t10\t0\t0\t0\t0\t0\t0\t%d\t%d\t0\t0\n" % (i, atompos, i-1, i+1));
    3737
    38 print "Parsing from "+inputfile
     38print("Parsing from "+inputfile)
    3939mol.WorldInput(inputfile)
    4040mol.SelectionAllAtoms()
     
    5353        print("Roots of p "+str(p)+" are "+str(zeros))
    5454        damping=numpy.real(zeros[-1])
    55         print "Using damping factor of "+str(damping)
     55        print("Using damping factor of "+str(damping))
    5656else:
    5757        if no_atoms == 2:
     
    8282                                        continue
    8383                                line=line.replace('\t',' ')
    84                                 print "LINE: "+line
     84                                print("LINE: "+line)
    8585                                [elementtype, X, Y, Z] = line.split(' ', 4)
    8686                                if coords!=[0.,0.,0.]:
     
    8888                                coords=[float(X),float(Y),float(Z)]
    8989        except IOError:
    90                 print 'Warning: '+outputfile+' not readable.'
     90                print('Warning: '+outputfile+' not readable.')
    9191                sys.exit(1)
    9292       
Note: See TracChangeset for help on using the changeset viewer.