diff --git a/python/grass/grassdb/testsuite/test_manage.py b/python/grass/grassdb/testsuite/test_manage.py index 007c54c4736..5b6880ce93f 100644 --- a/python/grass/grassdb/testsuite/test_manage.py +++ b/python/grass/grassdb/testsuite/test_manage.py @@ -10,13 +10,13 @@ """Tests of grass.grassdb.manage""" +import os from pathlib import Path from grass.grassdb.manage import MapsetPath, resolve_mapset_path, split_mapset_path from grass.gunittest.case import TestCase from grass.gunittest.gmodules import call_module from grass.gunittest.main import test -from grass.gunittest.utils import xfail_windows class TestMapsetPath(TestCase): @@ -37,7 +37,6 @@ def test_mapset_from_path_object(self): self.assertEqual(mapset_path.mapset, mapset_name) self.assertEqual(mapset_path.path, Path(path) / location_name / mapset_name) - @xfail_windows def test_mapset_from_str(self): """Check with path from str and database directory as Path""" path = "does/not/exist" @@ -51,7 +50,8 @@ def test_mapset_from_str(self): mapset=mapset_name, ) # Paths are currently stored as is (not resolved). - self.assertEqual(mapset_path.directory, path) + # pathlib uses os.sep for string representation of Path objects + self.assertEqual(mapset_path.directory, path.replace("/", os.sep)) self.assertEqual(mapset_path.location, location_name) self.assertEqual(mapset_path.mapset, mapset_name) self.assertEqual(mapset_path.path, Path(path) / location_name / mapset_name) @@ -60,7 +60,6 @@ def test_mapset_from_str(self): class TestSplitMapsetPath(TestCase): """Check that split works with different parameters""" - @xfail_windows def test_split_path(self): """Check that pathlib.Path is correctly split""" ref_db = "does/not/exist" @@ -68,11 +67,10 @@ def test_split_path(self): ref_mapset = "test_mapset_1" path = Path(ref_db) / ref_location / ref_mapset new_db, new_location, new_mapset = split_mapset_path(path) - self.assertEqual(new_db, ref_db) + self.assertEqual(new_db, ref_db.replace("/", os.sep)) self.assertEqual(new_location, ref_location) self.assertEqual(new_mapset, ref_mapset) - @xfail_windows def test_split_str(self): """Check that path as str is correctly split""" ref_db = "does/not/exist" @@ -80,11 +78,10 @@ def test_split_str(self): ref_mapset = "test_mapset_1" path = Path(ref_db) / ref_location / ref_mapset new_db, new_location, new_mapset = split_mapset_path(str(path)) - self.assertEqual(new_db, ref_db) + self.assertEqual(new_db, ref_db.replace("/", os.sep)) self.assertEqual(new_location, ref_location) self.assertEqual(new_mapset, ref_mapset) - @xfail_windows def test_split_str_trailing_slash(self): """Check that path as str with a trailing slash is correctly split""" ref_db = "does/not/exist" @@ -92,7 +89,7 @@ def test_split_str_trailing_slash(self): ref_mapset = "test_mapset_1" path = Path(ref_db) / ref_location / ref_mapset new_db, new_location, new_mapset = split_mapset_path(str(path) + "/") - self.assertEqual(new_db, ref_db) + self.assertEqual(new_db, ref_db.replace("/", os.sep)) self.assertEqual(new_location, ref_location) self.assertEqual(new_mapset, ref_mapset)