Skip to content

Commit

Permalink
more tear down
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and nyalldawson committed Feb 8, 2021
1 parent a0fd777 commit 6605163
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
19 changes: 11 additions & 8 deletions tests/src/python/test_qgsactionmanager.py
Expand Up @@ -35,21 +35,24 @@

class TestQgsActionManager(unittest.TestCase):

def __init__(self, methodName):
"""Run once on class initialization."""
unittest.TestCase.__init__(self, methodName)

self.layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer&field=flddate:datetime",
@classmethod
def setUpClass(cls):
cls.layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer&field=flddate:datetime",
"test_layer", "memory")
self.manager = QgsActionManager(self.layer)
cls.manager = QgsActionManager(cls.layer)

# make a little script to aid in recording action outputs
# this is just a little python file which writes out its arguments to a text file
self.run_script_file = os.path.join(QDir.tempPath(), 'run_action.py')
with open(self.run_script_file, 'w') as s:
cls.run_script_file = os.path.join(QDir.tempPath(), 'run_action.py')
with open(cls.run_script_file, 'w') as s:
s.write('import sys\n')
s.write('open(sys.argv[1], "w").write(" ".join(sys.argv[2:]))\n')

@classmethod
def tearDown(cls):
cls.layer = None
cls.manager = None

def get_temp_filename(self):
tmpFile = QTemporaryFile()
tmpFile.open() # fileName is no available until open
Expand Down
16 changes: 11 additions & 5 deletions tests/src/python/test_qgsrelationeditwidget.py
Expand Up @@ -96,13 +96,19 @@ def setUpClass(cls):
assert(cls.vl_editors.isValid())
assert(cls.vl_link_books_authors.isValid())

def setUp(self):
self.startTransaction()
@classmethod
def setUp(cls):
cls.startTransaction()

def tearDown(self):
self.rollbackTransaction()
del self.transaction
@classmethod
def tearDown(cls):
cls.rollbackTransaction()
del cls.transaction
QgsProject.instance().removeAllMapLayers()
cls.vl_books = None
cls.vl_authors = None
cls.vl_editors = None
cls.vl_link_books_authors = None

def test_delete_feature(self):
"""
Expand Down

0 comments on commit 6605163

Please sign in to comment.