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): class TestQgsActionManager(unittest.TestCase):


def __init__(self, methodName): @classmethod
"""Run once on class initialization.""" def setUpClass(cls):
unittest.TestCase.__init__(self, methodName) cls.layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer&field=flddate:datetime",

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


# make a little script to aid in recording action outputs # 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 # 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') cls.run_script_file = os.path.join(QDir.tempPath(), 'run_action.py')
with open(self.run_script_file, 'w') as s: with open(cls.run_script_file, 'w') as s:
s.write('import sys\n') s.write('import sys\n')
s.write('open(sys.argv[1], "w").write(" ".join(sys.argv[2:]))\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): def get_temp_filename(self):
tmpFile = QTemporaryFile() tmpFile = QTemporaryFile()
tmpFile.open() # fileName is no available until open 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_editors.isValid())
assert(cls.vl_link_books_authors.isValid()) assert(cls.vl_link_books_authors.isValid())


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


def tearDown(self): @classmethod
self.rollbackTransaction() def tearDown(cls):
del self.transaction cls.rollbackTransaction()
del cls.transaction
QgsProject.instance().removeAllMapLayers() 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): def test_delete_feature(self):
""" """
Expand Down

0 comments on commit 6605163

Please sign in to comment.