Skip to content
Permalink
Browse files

speedup creation of spatialite database in tests

  • Loading branch information
jef-n committed Aug 25, 2013
1 parent 43fc36a commit bb798b4ab3f3609b8cca0edbda01ab89b8cc8d0b
Showing with 9 additions and 7 deletions.
  1. +3 −2 tests/src/python/test_qgsissue7244.py
  2. +6 −5 tests/src/python/test_qgsspatialiteprovider.py
@@ -41,8 +41,9 @@ def setUpClass(cls):
# create test db
if os.path.exists("test.sqlite") :
os.remove("test.sqlite")
con = sqlite3.connect("test.sqlite")
con = sqlite3.connect("test.sqlite", isolation_level=None)
cur = con.cursor()
cur.execute("BEGIN")
sql = "SELECT InitSpatialMetadata()"
cur.execute(sql)

@@ -73,7 +74,7 @@ def setUpClass(cls):
sql = "INSERT INTO test_pg (name, geometry) "
sql += "VALUES ('polygon with interior ring', GeomFromText('POLYGON((0 0,3 0,3 3,0 3,0 0),(1 1,1 2,2 2,2 1,1 1))', 4326))"
cur.execute(sql)
con.commit()
cur.execute("COMMIT")
con.close()

@classmethod
@@ -43,11 +43,12 @@ class TestQgsSpatialiteProvider(TestCase):
def setUpClass(cls):
"""Run before all tests"""
# create test db
cls.dbname = os.path.join( tempfile.gettempdir(), "test.sqlite" )
cls.dbname = os.path.join( tempfile.gettempdir(), "test.sqlite" )
if os.path.exists( cls.dbname ):
os.remove( cls.dbname )
con = sqlite3.connect(cls.dbname)
con = sqlite3.connect(cls.dbname, isolation_level=None)
cur = con.cursor()
cur.execute( "BEGIN" )
sql = "SELECT InitSpatialMetadata()"
cur.execute(sql)

@@ -69,7 +70,7 @@ def setUpClass(cls):
sql += "VALUES (1, 'toto', GeomFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))', 4326))"
cur.execute(sql)

con.commit()
cur.execute( "COMMIT" )
con.close()

@classmethod
@@ -97,7 +98,7 @@ def test_SplitFeature(self):
layer.splitFeatures([QgsPoint(0.5, -0.5), QgsPoint(0.5, 1.5)], 0)==0 or die("error in split")
layer.splitFeatures([QgsPoint(-0.5, 0.5), QgsPoint(1.5, 0.5)], 0)==0 or die("error in split")
if not layer.commitChanges():
die("this commit should work")
die("this commit should work")
layer.featureCount() == 4 or die("we should have 4 features after 2 split")

def xtest_SplitFeatureWithFailedCommit(self):
@@ -109,7 +110,7 @@ def xtest_SplitFeatureWithFailedCommit(self):
layer.splitFeatures([QgsPoint(0.5, -0.5), QgsPoint(0.5, 1.5)], 0)==0 or die("error in split")
layer.splitFeatures([QgsPoint(-0.5, 0.5), QgsPoint(1.5, 0.5)], 0)==0 or die("error in split")
if layer.commitChanges():
die("this commit should fail")
die("this commit should fail")
layer.rollBack()
feat = QgsFeature()
it=layer.getFeatures()

0 comments on commit bb798b4

Please sign in to comment.
You can’t perform that action at this time.