33from itertools import product
44from math import degrees
55import copy
6- from path import Path
6+ from pathlib import Path
77from pathlib import PurePath
88import re
99from pytest import approx
4141
4242@pytest .fixture (scope = "function" )
4343def tmpdir (tmp_path_factory ):
44- return Path ( tmp_path_factory .mktemp ("assembly" ) )
44+ return tmp_path_factory .mktemp ("assembly" )
4545
4646
4747@pytest .fixture
@@ -557,18 +557,6 @@ def find_node(node_list, name_path):
557557 :param name_path: list of node names (corresponding to path)
558558 """
559559
560- def purepath_is_relative_to (p0 , p1 ):
561- """Alternative to PurePath.is_relative_to for Python 3.8
562- PurePath.is_relative_to is new in Python 3.9
563- """
564- try :
565- if p0 .relative_to (p1 ):
566- is_relative_to = True
567- except ValueError :
568- is_relative_to = False
569-
570- return is_relative_to
571-
572560 def get_nodes (node_list , name , parents ):
573561 if parents :
574562 nodes = []
@@ -577,8 +565,7 @@ def get_nodes(node_list, name, parents):
577565 [
578566 p
579567 for p in node_list
580- # if p["path"].is_relative_to(parent["path"])
581- if purepath_is_relative_to (p ["path" ], parent ["path" ])
568+ if p ["path" ].is_relative_to (parent ["path" ])
582569 and len (p ["path" ].relative_to (parent ["path" ]).parents ) == 1
583570 and re .fullmatch (name , p ["name" ])
584571 and p not in nodes
@@ -1376,18 +1363,18 @@ def test_save(extension, args, nested_assy, nested_assy_sphere):
13761363 ("stl" , ("STL" ,), {}),
13771364 ],
13781365)
1379- def test_export (extension , args , kwargs , tmpdir , nested_assy ):
1366+ def test_export (extension , args , kwargs , tmpdir , nested_assy , cwd ):
13801367
13811368 filename = "nested." + extension
13821369
1383- with tmpdir :
1370+ with cwd ( tmpdir ) :
13841371 nested_assy .export (filename , * args , ** kwargs )
13851372 assert os .path .exists (filename )
13861373
13871374
1388- def test_export_vtkjs (tmpdir , nested_assy ):
1375+ def test_export_vtkjs (tmpdir , nested_assy , cwd ):
13891376
1390- with tmpdir :
1377+ with cwd ( tmpdir ) :
13911378 nested_assy .export ("nested.vtkjs" )
13921379 assert os .path .exists ("nested.vtkjs.zip" )
13931380
@@ -1553,7 +1540,7 @@ def test_colors_assy0(assy_fixture, request, tmpdir, kind):
15531540 """
15541541
15551542 assy = request .getfixturevalue (assy_fixture )
1556- stepfile = ( Path (tmpdir ) / assy_fixture ).with_suffix (f".{ kind } " )
1543+ stepfile = str (( Path (tmpdir ) / assy_fixture ).with_suffix (f".{ kind } " ) )
15571544 assy .export (stepfile )
15581545
15591546 assy_i = assy .load (stepfile )
@@ -1585,7 +1572,7 @@ def test_colors_assy1(assy_fixture, request, tmpdir, kind):
15851572 """
15861573
15871574 assy = request .getfixturevalue (assy_fixture )
1588- stepfile = ( Path (tmpdir ) / assy_fixture ).with_suffix (f".{ kind } " )
1575+ stepfile = str (( Path (tmpdir ) / assy_fixture ).with_suffix (f".{ kind } " ) )
15891576 assy .export (stepfile )
15901577
15911578 assy_i = assy .load (stepfile )
0 commit comments