-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "_sigh_, removing this code is easiest, not crucial enough to …
…warrant a rewrite" This reverts commit 78cb203.
- Loading branch information
Showing
4 changed files
with
112 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
unit tests for 'utils.filesystem' module | ||
""" | ||
import os | ||
from rez.tests.util import TestBase | ||
from rez.utils import filesystem | ||
from rez.utils.platform_ import Platform, platform_ | ||
|
||
|
||
class TestCanonicalPath(TestBase): | ||
class CaseSensitivePlatform(Platform): | ||
@property | ||
def has_case_sensitive_filesystem(self): | ||
return True | ||
|
||
class CaseInsensitivePlatform(Platform): | ||
@property | ||
def has_case_sensitive_filesystem(self): | ||
return False | ||
|
||
def test_win32_case_insensitive(self): | ||
if platform_.name != 'windows': | ||
self.skipTest('on linux/macos, `os.path.realpath()` treats windows ' | ||
'abspaths as relpaths, and prepends `os.getcwd()`') | ||
platform = self.CaseInsensitivePlatform() | ||
path = filesystem.canonical_path('C:\\dir\\File.txt', platform) | ||
expects = 'c:\\dir\\file.txt'.replace('\\', os.sep) | ||
self.assertEqual(path, expects) | ||
|
||
def test_unix_case_sensistive_platform(self): | ||
if platform_.name == 'windows': | ||
self.skipTest('on windows, `os.path.realpath()` treats unix abspaths ' | ||
'as relpaths, and prepends `os.getcwd()`') | ||
platform = self.CaseSensitivePlatform() | ||
path = filesystem.canonical_path('/a/b/File.txt', platform) | ||
expects = '/a/b/File.txt'.replace('\\', os.sep) | ||
self.assertEqual(path, expects) | ||
|
||
def test_unix_case_insensistive_platform(self): | ||
if platform_.name == 'windows': | ||
self.skipTest('on windows, `os.path.realpath()` treats unix abspaths ' | ||
'as relpaths, and prepends `os.getcwd()`') | ||
platform = self.CaseInsensitivePlatform() | ||
path = filesystem.canonical_path('/a/b/File.txt', platform) | ||
expects = '/a/b/file.txt'.replace('\\', os.sep) | ||
self.assertEqual(path, expects) | ||
|
||
|
||
# Copyright 2013-2016 Allan Johns. | ||
# | ||
# This library is free software: you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation, either | ||
# version 3 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library. If not, see <http://www.gnu.org/licenses/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters