Draft: Introduce base classes for Draft tests
To avoid code duplication.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2013 Yorik van Havre <yorik@uncreated.net> *
|
||||
# * Copyright (c) 2019 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de> *
|
||||
# * Copyright (c) 2025 FreeCAD Project Association *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -29,35 +30,18 @@
|
||||
## \addtogroup drafttests
|
||||
# @{
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import FreeCAD as App
|
||||
import Draft
|
||||
import drafttests.auxiliary as aux
|
||||
|
||||
from draftutils.messages import _msg
|
||||
from drafttests import test_base
|
||||
|
||||
|
||||
class DraftOCA(unittest.TestCase):
|
||||
class DraftOCA(test_base.DraftTestCaseDoc):
|
||||
"""Test reading and writing of OCA files with Draft."""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up a new document to hold the tests.
|
||||
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
App.newDocument(self.doc_name)
|
||||
else:
|
||||
App.newDocument(self.doc_name)
|
||||
App.setActiveDocument(self.doc_name)
|
||||
self.doc = App.ActiveDocument
|
||||
_msg(" Temporary document '{}'".format(self.doc_name))
|
||||
|
||||
def test_read_oca(self):
|
||||
"""Read an OCA file and import its elements as Draft objects."""
|
||||
operation = "importOCA.import"
|
||||
@@ -87,11 +71,4 @@ class DraftOCA(unittest.TestCase):
|
||||
obj = Draft.export_oca(out_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def tearDown(self):
|
||||
"""Finish the test.
|
||||
|
||||
This is executed after each test, so we close the document.
|
||||
"""
|
||||
App.closeDocument(self.doc_name)
|
||||
|
||||
## @}
|
||||
|
||||
Reference in New Issue
Block a user