44import tempfile
55import warnings
66from pathlib import Path
7- from sys import version_info
87from typing import Callable
98
109import numpy as np
@@ -1574,7 +1573,7 @@ def test_save_load(project, request):
15741573
15751574
15761575def test_relative_paths ():
1577- """Test that ``try_relative_to`` correctly creates relative paths."""
1576+ """Test that ``try_relative_to`` correctly creates relative paths to subfolders ."""
15781577
15791578 with tempfile .TemporaryDirectory () as tmp :
15801579 data_path = Path (tmp , "data/myfile.dat" )
@@ -1583,19 +1582,16 @@ def test_relative_paths():
15831582
15841583
15851584def test_relative_paths_version ():
1586- """Test that we only walk up paths on Python 3.12 or greater ."""
1585+ """Test that we get a warning for trying to walk up paths ."""
15871586
15881587 data_path = "/tmp/project/data/mydata.dat"
15891588 relative_path = "/tmp/project/project_path/myproj.dat"
15901589
1591- if version_info .minor >= 12 :
1592- with warnings .catch_warnings ():
1593- warnings .simplefilter ("error" )
1594- assert RATapi .project .try_relative_to (data_path , relative_path ) == Path ("../../data/mydata.dat" )
1595- else :
1596- with pytest .warns (
1597- match = "Could not save a custom file path as relative to the project directory. "
1598- "This may mean the project may not open on other devices. "
1599- "Error message:"
1600- ):
1601- assert RATapi .project .try_relative_to (data_path , relative_path ) == Path ("/tmp/project/data/mydata.dat" )
1590+ with pytest .warns (
1591+ match = "Could not save custom file path as relative to the project directory. "
1592+ "To ensure that your project works on other devices, make sure your custom files "
1593+ "are in a subfolder of the project save location."
1594+ ):
1595+ assert (
1596+ RATapi .project .try_relative_to (data_path , relative_path ) == Path ("/tmp/project/data/mydata.dat" ).resolve ()
1597+ )
0 commit comments