Draft: Introduce base classes for Draft tests

To avoid code duplication.
This commit is contained in:
Roy-043
2025-01-03 16:51:42 +01:00
parent 7b548bee7f
commit 0bc9737ca6
14 changed files with 157 additions and 345 deletions

View File

@@ -1,5 +1,6 @@
# ***************************************************************************
# * Copyright (c) 2023 Werner Mayer <wmayer[at]users.sourceforge.net> *
# * Copyright (c) 2025 FreeCAD Project Association *
# * *
# * This file is part of FreeCAD. *
# * *
@@ -25,7 +26,6 @@
## \addtogroup drafttests
# @{
import unittest
import math
import FreeCAD as App
@@ -33,27 +33,12 @@ import Draft
from FreeCAD import Vector
from draftutils.messages import _msg
from drafttests import test_base
class DraftArray(unittest.TestCase):
class DraftArray(test_base.DraftTestCaseDoc):
"""Test Draft array functions."""
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.
"""
doc_name = self.__class__.__name__
if App.ActiveDocument:
if App.ActiveDocument.Name != doc_name:
App.newDocument(doc_name)
else:
App.newDocument(doc_name)
App.setActiveDocument(doc_name)
self.doc = App.ActiveDocument
_msg(" Temporary document '{}'".format(self.doc.Name))
def test_link_array(self):
"""Create a link array."""
box = self.doc.addObject("Part::Box","Box")
@@ -81,11 +66,4 @@ class DraftArray(unittest.TestCase):
self.doc.recompute(None,True,True)
self.assertEqual(array.Count, array.NumberX)
def tearDown(self):
"""Finish the test.
This is executed after each test, so we close the document.
"""
App.closeDocument(self.doc.Name)
## @}