On Wed, Dec 16, 2020 at 09:21:09AM +0100, Landry Breuil wrote:
> On Tue, Dec 15, 2020 at 08:55:48PM -0600, Lucas Raab wrote:
> > Hello,
> >
> > Following up on the call for testers on barman, I am wondering if there
> > are users of:
> >
> > * databases/pgloader
> > * databases/skytools
> > * databases/py-pg_activity
> > * geo/osm2pgsql
>
> if you look at your diff, psycopg2 is used when running tests.. that you
> havent even run ;)
>
> waiting for server to start.... done
> server started
> File "tests/regression-test.py", line 345
> print "I am unable to connect to the database." + e
> ^
> SyntaxError: Missing parentheses in call to 'print'. Did you mean
> print("I am unable to connect to the database." + e)?
with the attached patch, i can run the osm2pgsql tests of the old 0.96.0
version we have in-tree with py3.
Landry
$OpenBSD: patch-tests_regression-test_py,v 1.2 2018/10/28 14:49:25 landry Exp $
make that thing py3
Index: tests/regression-test.py
--- tests/regression-test.py.orig
+++ tests/regression-test.py
@@ -342,14 +342,14 @@ class BaseTestCase(unittest.TestCase):
self.conn.autocommit = True
self.cur = self.conn.cursor()
except Exception as e:
- print "I am unable to connect to the database." + e
+ print("I am unable to connect to the database." + e)
def dbClose(self):
self.cur.close()
self.conn.close()
def executeStatements(self, seq):
- print "*********************************"
+ print ("*********************************")
self.dbConnect()
try:
for i in seq:
@@ -418,8 +418,8 @@ class BasicNonSlimTestCase(BaseNonSlimTestCase):
self.setUpGeneric(self.parameters, full_import_file)
def runTest(self):
- print "****************************************"
- print "Running initial import for " + self.name
+ print ("****************************************")
+ print ("Running initial import for " + self.name)
self.executeStatements(self.initialStatements)
@@ -437,10 +437,10 @@ class BasicSlimTestCase(BaseSlimTestCase):
def runTest(self):
- print "****************************************"
- print "Running initial import for " + self.name
+ print ("****************************************")
+ print ("Running initial import for " + self.name)
self.executeStatements(self.initialStatements)
- print "Running diff-import for " + self.name
+ print ("Running diff-import for " + self.name)
self.updateGeneric(self.parameters, diff_import_file)
self.executeStatements(self.postDiffStatements)
@@ -458,10 +458,10 @@ class MultipolygonSlimTestCase(BaseSlimTestCase):
def runTest(self):
- print "****************************************"
- print "Running initial import for " + self.name
+ print ("****************************************")
+ print ("Running initial import for " + self.name)
self.executeStatements(self.initialStatements)
- print "Running diff-import for " + self.name
+ print ("Running diff-import for " + self.name)
self.updateGeneric(self.parameters, diff_multipoly_import_file)
self.executeStatements(self.postDiffStatements)
@@ -480,10 +480,10 @@ class BasicGazetteerTestCase(BaseGazetteerTestCase):
def runTest(self):
- print "****************************************"
- print "Running initial import in gazetteer mode for " + self.name
+ print ("****************************************")
+ print ("Running initial import in gazetteer mode for " + self.name)
self.executeStatements(self.initialStatements)
- print "Running diff-import in gazetteer mode for " + self.name
+ print ("Running diff-import in gazetteer mode for " + self.name)
self.updateGeneric(self.parameters, diff_import_file)
self.executeStatements(self.postDiffStatements)
@@ -494,7 +494,7 @@ def findContribSql(filename):
# Try to get base dir for postgres contrib
try:
- postgis_base_dir = os.popen('pg_config | grep -m 1 "^INCLUDEDIR
="').read().strip().split(' ')[2].split('/include')[0]
+ postgis_base_dir = os.popen('pg_config | grep "^INCLUDEDIR =" |head
-n1').read().strip().split(' ')[2].split('/include')[0]
except:
postgis_base_dir = '/usr'
@@ -508,26 +508,26 @@ def findContribSql(filename):
#****************************************************************
#****************************************************************
def setupDB():
- print "Setting up test database"
+ print ("Setting up test database")
try:
gen_conn=psycopg2.connect("dbname='template1'")
gen_conn.autocommit = True
except Exception as e:
- print "I am unable to connect to the database."
+ print ("I am unable to connect to the database.")
exit(1)
try:
gen_cur = gen_conn.cursor()
except Exception as e:
gen_conn.close()
- print "I am unable to connect to the database."
+ print ("I am unable to connect to the database.")
exit(1)
try:
gen_cur.execute("""DROP DATABASE IF EXISTS \"osm2pgsql-test\"""")
gen_cur.execute("""CREATE DATABASE \"osm2pgsql-test\" WITH ENCODING
'UTF8'""")
except Exception as e:
- print "Failed to create osm2pgsql-test db" + e.pgerror
+ print ("Failed to create osm2pgsql-test db" + e.pgerror)
exit(1);
finally:
gen_cur.close()
@@ -537,13 +537,13 @@ def setupDB():
test_conn=psycopg2.connect("dbname='osm2pgsql-test'")
test_conn.autocommit = True
except Exception as e:
- print "I am unable to connect to the database." + e
+ print ("I am unable to connect to the database." + e)
exit(1)
try:
test_cur = test_conn.cursor()
except Exception as e:
- print "I am unable to connect to the database." + e
+ print ("I am unable to connect to the database." + e)
gen_conn.close()
exit(1)
@@ -554,17 +554,20 @@ def setupDB():
global created_tablespace
created_tablespace = 0
+ subprocess.call(["/bin/rm", "-rf", "/tmp/psql-tablespace"])
+ os.makedirs("/tmp/psql-tablespace")
+ test_cur.execute("""CREATE TABLESPACE tablespacetest LOCATION
'/tmp/psql-tablespace'""")
test_cur.execute("""SELECT spcname FROM pg_tablespace WHERE
spcname = 'tablespacetest'""")
if test_cur.fetchone():
- print "We already have a tablespace, can use that"
+ print ("We already have a tablespace, can use that")
else:
- 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:"
- print " sudo mkdir -p /tmp/psql-tablespace"
- print " sudo /bin/chown postgres.postgres
/tmp/psql-tablespace"
- print " psql -c \"CREATE TABLESPACE tablespacetest LOCATION
'/tmp/psql-tablespace'\" postgres"
+ 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:")
+ print (" sudo mkdir -p /tmp/psql-tablespace")
+ print (" sudo /bin/chown postgres.postgres
/tmp/psql-tablespace")
+ print (" psql -c \"CREATE TABLESPACE tablespacetest LOCATION
'/tmp/psql-tablespace'\" postgres")
exit(77)
except Exception as e:
- print "Failed to create directory for tablespace" + str(e)
+ print ("Failed to create directory for tablespace" + str(e))
# Check for postgis
try:
@@ -593,13 +596,13 @@ def setupDB():
test_conn.close()
def tearDownDB():
- print "Cleaning up test database"
+ print ("Cleaning up test database")
try:
gen_conn=psycopg2.connect("dbname='template1'")
gen_conn.autocommit = True
gen_cur = gen_conn.cursor()
except Exception as e:
- print "I am unable to connect to the database."
+ print ("I am unable to connect to the database.")
exit(1)
try:
@@ -607,13 +610,13 @@ def tearDownDB():
if (created_tablespace == 1):
gen_cur.execute("""DROP TABLESPACE IF EXISTS \"tablespacetest\"""")
except Exception as e:
- print "Failed to clean up osm2pgsql-test db" + e.pgerror
+ print ("Failed to clean up osm2pgsql-test db" + e.pgerror)
exit(1);
gen_cur.close()
gen_conn.close()
if (created_tablespace == 1):
- returncode = subprocess.call(["/usr/bin/sudo", "/bin/rmdir",
"/tmp/psql-tablespace"])
+ returncode = subprocess.call(["/bin/rm", "-rf",
"/tmp/psql-tablespace"])
if __name__ == "__main__":
@@ -646,8 +649,8 @@ finally:
tearDownDB()
if success:
- print "All tests passed :-)"
+ print ("All tests passed :-)")
exit(0)
else:
- print "Some tests failed :-("
+ print ("Some tests failed :-(")
exit(1)