Skip to content

Commit ea23dc9

Browse files
authored
Merge pull request #939 from sebastic/python3
Use Python 3 for regression-test.py.
2 parents 90e17f0 + c89b143 commit ea23dc9

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ addons_shortcuts:
1414
apt:
1515
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-3.8']
1616
packages: ['clang-3.8', 'postgresql-9.2-postgis-2.3',
17-
'python-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
17+
'python3-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
1818
'lua5.2', 'liblua5.2-dev', 'libluajit-5.1-dev',
1919
'libboost1.55-dev', 'libboost-system1.55-dev', 'libboost-filesystem1.55-dev']
2020

@@ -27,7 +27,7 @@ addons_shortcuts:
2727
key_url: https://apt.llvm.org/llvm-snapshot.gpg.key
2828
- ubuntu-toolchain-r-test
2929
packages: ['clang-7','postgresql-9.6-postgis-2.3',
30-
'python-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
30+
'python3-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
3131
'lua5.2', 'liblua5.2-dev', 'libluajit-5.1-dev',
3232
'libboost1.55-dev', 'libboost-system1.55-dev', 'libboost-filesystem1.55-dev']
3333

@@ -36,7 +36,7 @@ addons_shortcuts:
3636
apt:
3737
sources: ["ubuntu-toolchain-r-test"]
3838
packages: ['g++-4.8','postgresql-9.6-postgis-2.3',
39-
'python-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
39+
'python3-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
4040
'lua5.2', 'liblua5.2-dev', 'libluajit-5.1-dev',
4141
'libboost1.55-dev', 'libboost-system1.55-dev', 'libboost-filesystem1.55-dev']
4242

@@ -46,7 +46,7 @@ addons_shortcuts:
4646
apt:
4747
sources: ["ubuntu-toolchain-r-test"]
4848
packages: ['g++-8','postgresql-9.6-postgis-2.3',
49-
'python-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
49+
'python3-psycopg2', 'libexpat1-dev', 'libpq-dev', 'libbz2-dev', 'libproj-dev',
5050
'lua5.2', 'liblua5.2-dev', 'libluajit-5.1-dev',
5151
'libboost1.55-dev', 'libboost-system1.55-dev', 'libboost-filesystem1.55-dev']
5252

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ executing ``ctest``.
7373
Regression tests require python and psycopg to be installed. On Ubuntu run:
7474

7575
```sh
76-
sudo apt-get install python-psycopg2
76+
sudo apt-get install python3-psycopg2
7777
```
7878

7979
Most of these tests depend on being able to set up a database and run osm2pgsql

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ if (NOT HAVE_LUA)
8282
set_tests_properties(test-output-multi-tags PROPERTIES WILL_FAIL on)
8383
endif()
8484

85-
find_package(PythonInterp)
85+
find_package(PythonInterp 3)
8686

8787
if (PYTHONINTERP_FOUND)
8888
add_test(NAME regression-test-pbf COMMAND ${PYTHON_EXECUTABLE} tests/regression-test.py -f tests/liechtenstein-2013-08-03.osm.pbf -x $<TARGET_FILE:osm2pgsql>

tests/regression-test.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import unittest
44
import 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
#****************************************************************
485485
def 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

570570
def 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

623623
if success:
624-
print "All tests passed :-)"
624+
print("All tests passed :-)")
625625
exit(0)
626626
else:
627-
print "Some tests failed :-("
627+
print("Some tests failed :-(")
628628
exit(1)

0 commit comments

Comments
 (0)