@@ -1574,7 +1574,7 @@ def test_save_load(project, request):
15741574
15751575
15761576def test_relative_paths ():
1577- """Test that ``try_relative_to`` correctly creates relative paths."""
1577+ """Test that ``try_relative_to`` correctly creates relative paths to subfolders ."""
15781578
15791579 with tempfile .TemporaryDirectory () as tmp :
15801580 data_path = Path (tmp , "data/myfile.dat" )
@@ -1583,19 +1583,17 @@ def test_relative_paths():
15831583
15841584
15851585def test_relative_paths_version ():
1586- """Test that we only walk up paths on Python 3.12 or greater ."""
1586+ """Test that we get a warning for trying to walk up paths ."""
15871587
15881588 data_path = "/tmp/project/data/mydata.dat"
15891589 relative_path = "/tmp/project/project_path/myproj.dat"
15901590
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" )
1591+ with pytest .warns (
1592+ match = "Could not save custom file path as relative to the project directory. "
1593+ "To ensure that your project works on other devices, make sure your custom files "
1594+ "are in a subfolder of the project save location."
1595+ ):
1596+ assert (
1597+ RATapi .project .try_relative_to (data_path , relative_path )
1598+ == Path ("/tmp/project/data/mydata.dat" ).resolve ()
1599+ )
0 commit comments