1- #!/usr/bin/env python
1+ #!/usr/bin/env python3
22
33import unittest
44import psycopg2
@@ -317,14 +317,14 @@ def dbConnect(self):
317317 self .conn .autocommit = True
318318 self .cur = self .conn .cursor ()
319319 except Exception as e :
320- print "I am unable to connect to the database." + e
320+ print ( "I am unable to connect to the database." + e )
321321
322322 def dbClose (self ):
323323 self .cur .close ()
324324 self .conn .close ()
325325
326326 def executeStatements (self , seq ):
327- print "*********************************"
327+ print ( "*********************************" )
328328 self .dbConnect ()
329329 try :
330330 for i in seq :
@@ -393,8 +393,8 @@ def setUp(self):
393393 self .setUpGeneric (self .parameters , full_import_file )
394394
395395 def runTest (self ):
396- print "****************************************"
397- print "Running initial import for " + self .name
396+ print ( "****************************************" )
397+ print ( "Running initial import for " + self .name )
398398 self .executeStatements (self .initialStatements )
399399
400400
@@ -412,10 +412,10 @@ def setUp(self):
412412
413413
414414 def runTest (self ):
415- print "****************************************"
416- print "Running initial import for " + self .name
415+ print ( "****************************************" )
416+ print ( "Running initial import for " + self .name )
417417 self .executeStatements (self .initialStatements )
418- print "Running diff-import for " + self .name
418+ print ( "Running diff-import for " + self .name )
419419 self .updateGeneric (self .parameters , diff_import_file )
420420 self .executeStatements (self .postDiffStatements )
421421
@@ -433,10 +433,10 @@ def setUp(self):
433433
434434
435435 def runTest (self ):
436- print "****************************************"
437- print "Running initial import for " + self .name
436+ print ( "****************************************" )
437+ print ( "Running initial import for " + self .name )
438438 self .executeStatements (self .initialStatements )
439- print "Running diff-import for " + self .name
439+ print ( "Running diff-import for " + self .name )
440440 self .updateGeneric (self .parameters , diff_multipoly_import_file )
441441 self .executeStatements (self .postDiffStatements )
442442
@@ -455,10 +455,10 @@ def setUp(self):
455455
456456
457457 def runTest (self ):
458- print "****************************************"
459- print "Running initial import in gazetteer mode for " + self .name
458+ print ( "****************************************" )
459+ print ( "Running initial import in gazetteer mode for " + self .name )
460460 self .executeStatements (self .initialStatements )
461- print "Running diff-import in gazetteer mode for " + self .name
461+ print ( "Running diff-import in gazetteer mode for " + self .name )
462462 self .updateGeneric (self .parameters , diff_import_file )
463463 self .executeStatements (self .postDiffStatements )
464464
@@ -483,26 +483,26 @@ def findContribSql(filename):
483483#****************************************************************
484484#****************************************************************
485485def setupDB ():
486- print "Setting up test database"
486+ print ( "Setting up test database" )
487487 try :
488488 gen_conn = psycopg2 .connect ("dbname='template1'" )
489489 gen_conn .autocommit = True
490490 except Exception as e :
491- print "I am unable to connect to the database."
491+ print ( "I am unable to connect to the database." )
492492 exit (1 )
493493
494494 try :
495495 gen_cur = gen_conn .cursor ()
496496 except Exception as e :
497497 gen_conn .close ()
498- print "I am unable to connect to the database."
498+ print ( "I am unable to connect to the database." )
499499 exit (1 )
500500
501501 try :
502502 gen_cur .execute ("""DROP DATABASE IF EXISTS \" osm2pgsql-test\" """ )
503503 gen_cur .execute ("""CREATE DATABASE \" osm2pgsql-test\" WITH ENCODING 'UTF8'""" )
504504 except Exception as e :
505- print "Failed to create osm2pgsql-test db" + e .pgerror
505+ print ( "Failed to create osm2pgsql-test db" + e .pgerror )
506506 exit (1 );
507507 finally :
508508 gen_cur .close ()
@@ -512,13 +512,13 @@ def setupDB():
512512 test_conn = psycopg2 .connect ("dbname='osm2pgsql-test'" )
513513 test_conn .autocommit = True
514514 except Exception as e :
515- print "I am unable to connect to the database." + e
515+ print ( "I am unable to connect to the database." + e )
516516 exit (1 )
517517
518518 try :
519519 test_cur = test_conn .cursor ()
520520 except Exception as e :
521- print "I am unable to connect to the database." + e
521+ print ( "I am unable to connect to the database." + e )
522522 gen_conn .close ()
523523 exit (1 )
524524
@@ -531,15 +531,15 @@ def setupDB():
531531
532532 test_cur .execute ("""SELECT spcname FROM pg_tablespace WHERE spcname = 'tablespacetest'""" )
533533 if test_cur .fetchone ():
534- print "We already have a tablespace, can use that"
534+ print ( "We already have a tablespace, can use that" )
535535 else :
536- print "The test needs a temporary tablespace to run in, but it does not exist. Please create the temporary tablespace. On Linux, you can do this by running:"
537- print " sudo mkdir -p /tmp/psql-tablespace"
538- print " sudo /bin/chown postgres.postgres /tmp/psql-tablespace"
539- print " psql -c \" CREATE TABLESPACE tablespacetest LOCATION '/tmp/psql-tablespace'\" postgres"
536+ print ( "The test needs a temporary tablespace to run in, but it does not exist. Please create the temporary tablespace. On Linux, you can do this by running:" )
537+ print ( " sudo mkdir -p /tmp/psql-tablespace" )
538+ print ( " sudo /bin/chown postgres.postgres /tmp/psql-tablespace" )
539+ print ( " psql -c \" CREATE TABLESPACE tablespacetest LOCATION '/tmp/psql-tablespace'\" postgres" )
540540 exit (77 )
541541 except Exception as e :
542- print "Failed to create directory for tablespace" + str (e )
542+ print ( "Failed to create directory for tablespace" + str (e ) )
543543
544544 # Check for postgis
545545 try :
@@ -568,21 +568,21 @@ def setupDB():
568568 test_conn .close ()
569569
570570def tearDownDB ():
571- print "Cleaning up test database"
571+ print ( "Cleaning up test database" )
572572 try :
573573 gen_conn = psycopg2 .connect ("dbname='template1'" )
574574 gen_conn .autocommit = True
575575 gen_cur = gen_conn .cursor ()
576576 except Exception as e :
577- print "I am unable to connect to the database."
577+ print ( "I am unable to connect to the database." )
578578 exit (1 )
579579
580580 try :
581581 gen_cur .execute ("""DROP DATABASE IF EXISTS \" osm2pgsql-test\" """ )
582582 if (created_tablespace == 1 ):
583583 gen_cur .execute ("""DROP TABLESPACE IF EXISTS \" tablespacetest\" """ )
584584 except Exception as e :
585- print "Failed to clean up osm2pgsql-test db" + e .pgerror
585+ print ( "Failed to clean up osm2pgsql-test db" + e .pgerror )
586586 exit (1 );
587587
588588 gen_cur .close ()
@@ -621,8 +621,8 @@ def tearDownDB():
621621 tearDownDB ()
622622
623623if success :
624- print "All tests passed :-)"
624+ print ( "All tests passed :-)" )
625625 exit (0 )
626626else :
627- print "Some tests failed :-("
627+ print ( "Some tests failed :-(" )
628628 exit (1 )
0 commit comments