4
4
"""
5
5
# system modules
6
6
import math , os .path , time , tempfile
7
+ from pathlib import Path
7
8
from random import random
8
9
from random import randrange
9
10
from itertools import product
24
25
)
25
26
26
27
# test data directory
27
- testdataDir = os .path .join (os .path .dirname (__file__ ), "testdata" )
28
+ testdataDir = Path (__file__ ).parent .joinpath ("testdata" )
29
+ testFont = str (testdataDir / "OpenSans-Regular.ttf" )
28
30
29
31
# where unit test output will be saved
30
32
OUTDIR = tempfile .gettempdir ()
@@ -3843,7 +3845,7 @@ def testText(self):
3843
3845
"CQ 2.0" ,
3844
3846
0.5 ,
3845
3847
0.05 ,
3846
- fontPath = os . path . join ( testdataDir , "OpenSans-Regular.ttf" ) ,
3848
+ fontPath = testFont ,
3847
3849
cut = False ,
3848
3850
combine = False ,
3849
3851
halign = "right" ,
@@ -3863,7 +3865,7 @@ def testText(self):
3863
3865
"CQ 2.0" ,
3864
3866
0.5 ,
3865
3867
0.05 ,
3866
- fontPath = os . path . join ( testdataDir , "OpenSans-Irregular.ttf" ) ,
3868
+ fontPath = testFont ,
3867
3869
cut = False ,
3868
3870
combine = False ,
3869
3871
halign = "right" ,
@@ -3885,17 +3887,23 @@ def testText(self):
3885
3887
)
3886
3888
3887
3889
def testTextAlignment (self ):
3888
- left_bottom = Workplane ().text ("I" , 10 , 0 , halign = "left" , valign = "bottom" )
3890
+ left_bottom = Workplane ().text (
3891
+ "I" , 10 , 0 , halign = "left" , valign = "bottom" , fontPath = testFont ,
3892
+ )
3889
3893
lb_bb = left_bottom .val ().BoundingBox ()
3890
3894
self .assertGreaterEqual (lb_bb .xmin , 0 )
3891
3895
self .assertGreaterEqual (lb_bb .ymin , 0 )
3892
3896
3893
- centers = Workplane ().text ("I" , 10 , 0 , halign = "center" , valign = "center" )
3897
+ centers = Workplane ().text (
3898
+ "I" , 10 , 0 , halign = "center" , valign = "center" , fontPath = testFont ,
3899
+ )
3894
3900
c_bb = centers .val ().BoundingBox ()
3895
3901
self .assertAlmostEqual (c_bb .center .x , 0 , places = 0 )
3896
3902
self .assertAlmostEqual (c_bb .center .y , 0 , places = 0 )
3897
3903
3898
- right_top = Workplane ().text ("I" , 10 , 0 , halign = "right" , valign = "top" )
3904
+ right_top = Workplane ().text (
3905
+ "I" , 10 , 0 , halign = "right" , valign = "top" , fontPath = testFont ,
3906
+ )
3899
3907
rt_bb = right_top .val ().BoundingBox ()
3900
3908
self .assertLessEqual (rt_bb .xmax , 0 )
3901
3909
self .assertLessEqual (rt_bb .ymax , 0 )
0 commit comments