本文整理汇总了Python中trace_inputs.get_native_path_case函数的典型用法代码示例。如果您正苦于以下问题:Python get_native_path_case函数的具体用法?Python get_native_path_case怎么用?Python get_native_path_case使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_native_path_case函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_native_case_windows
def test_native_case_windows(self):
if sys.platform != 'win32':
return
windows_path = os.environ['SystemRoot']
self.assertEquals(
trace_inputs.get_native_path_case(windows_path.lower()),
trace_inputs.get_native_path_case(windows_path.upper()))
示例2: test_native_case_symlink_wrong_case
def test_native_case_symlink_wrong_case(self):
actual = trace_inputs.get_native_path_case(
os.path.join(ROOT_DIR, 'data', 'trace_inputs'))
self.assertEquals('trace_inputs', os.path.basename(actual))
# Make sure the symlink is not resolved.
actual = trace_inputs.get_native_path_case(
os.path.join(ROOT_DIR, 'data', 'trace_inputs', 'Files2'))
self.assertEquals('files2', os.path.basename(actual))
示例3: test_native_case_not_sensitive_non_existent
def test_native_case_not_sensitive_non_existent(self):
# This test also ensures that the output is independent on the input
# string case.
non_existing = os.path.join(
'trace_input_test_this_dir_should_not_exist', 'really not', '')
path = os.path.expanduser(os.path.join('~', non_existing))
self.assertFalse(os.path.exists(path))
lower = trace_inputs.get_native_path_case(path.lower())
upper = trace_inputs.get_native_path_case(path.upper())
# Make sure non-existing element is not modified:
self.assertTrue(lower.endswith(non_existing.lower()))
self.assertTrue(upper.endswith(non_existing.upper()))
self.assertEquals(lower[:-len(non_existing)], upper[:-len(non_existing)])
示例4: test_native_case_not_sensitive
def test_native_case_not_sensitive(self):
# The home directory is almost guaranteed to have mixed upper/lower case
# letters on both Windows and OSX.
# This test also ensures that the output is independent on the input
# string case.
path = os.path.expanduser('~')
self.assertTrue(os.path.isdir(path))
# This test assumes the variable is in the native path case on disk, this
# should be the case. Verify this assumption:
self.assertEquals(path, trace_inputs.get_native_path_case(path))
self.assertEquals(
trace_inputs.get_native_path_case(path.lower()),
trace_inputs.get_native_path_case(path.upper()))
示例5: setUp
def setUp(self):
self.temp_file = None
self.initial_cwd = ROOT_DIR
if sys.platform == 'win32':
# Windows has no kernel mode concept of current working directory.
self.initial_cwd = None
# There's 2 kinds of references to python, self.executable,
# self.real_executable. It depends how python was started and on which OS.
self.executable = unicode(sys.executable)
if sys.platform == 'darwin':
# /usr/bin/python is a thunk executable that decides which version of
# python gets executed.
suffix = '.'.join(map(str, sys.version_info[0:2]))
if os.access(self.executable + suffix, os.X_OK):
# So it'll look like /usr/bin/python2.7
self.executable += suffix
self.real_executable = trace_inputs.get_native_path_case(
self.executable)
if sys.platform == 'darwin':
# Interestingly, only OSX does resolve the symlink manually before
# starting the executable.
if os.path.islink(self.real_executable):
self.real_executable = os.path.normpath(
os.path.join(
os.path.dirname(self.real_executable),
os.readlink(self.real_executable)))
示例6: parse_args
def parse_args(self, *args, **kwargs):
"""Makes sure the paths make sense.
On Windows, / and \ are often mixed together in a path.
"""
options, args = OptionParserWithLogging.parse_args(self, *args, **kwargs)
if not self.allow_interspersed_args and args:
self.error('Unsupported argument: %s' % args)
options.variables = dict(options.variables)
if self.require_result and not options.result:
self.error('--result is required.')
if options.result and not options.result.endswith('.results'):
self.error('--result value must end with \'.results\'')
if options.result:
options.result = os.path.abspath(options.result.replace('/', os.path.sep))
if options.isolate:
options.isolate = trace_inputs.get_native_path_case(
os.path.abspath(
options.isolate.replace('/', os.path.sep)))
if options.outdir:
options.outdir = os.path.abspath(
options.outdir.replace('/', os.path.sep))
return options, args
示例7: test_trace
def test_trace(self):
expected = self._gen_dict_full_gyp()
results = self._execute_trace(self.get_child_command(True))
actual = results.flatten()
self.assertTrue(actual['root'].pop('pid'))
self.assertTrue(actual['root']['children'][0].pop('pid'))
self.assertEqual(expected, actual)
files = [
u'tests/trace_inputs/child1.py'.replace('/', os.path.sep),
u'tests/trace_inputs/child2.py'.replace('/', os.path.sep),
u'tests/trace_inputs/files1/'.replace('/', os.path.sep),
u'tests/trace_inputs/test_file.txt'.replace('/', os.path.sep),
u'tests/trace_inputs_smoke_test.py'.replace('/', os.path.sep),
u'trace_inputs.py',
]
def blacklist(f):
return f.endswith(('.pyc', 'do_not_care.txt', '.git', '.svn'))
simplified = trace_inputs.extract_directories(
trace_inputs.get_native_path_case(unicode(ROOT_DIR)),
results.files,
blacklist)
self.assertEqual(files, [f.path for f in simplified])
示例8: setUp
def setUp(self):
self.temp_file = None
self.initial_cwd = ROOT_DIR
if sys.platform == 'win32':
# Windows has no kernel mode concept of current working directory.
self.initial_cwd = None
# There's 2 kinds of references to python, self.executable,
# self.real_executable. It depends how python was started and on which OS.
self.executable = unicode(sys.executable)
if sys.platform == 'darwin':
# /usr/bin/python is a thunk executable that decides which version of
# python gets executed.
suffix = '.'.join(map(str, sys.version_info[0:2]))
if os.access(self.executable + suffix, os.X_OK):
# So it'll look like /usr/bin/python2.7
self.executable += suffix
self.real_executable = trace_inputs.get_native_path_case(self.executable)
# Make sure there's no environment variable that could do side effects.
os.environ.pop('GTEST_SHARD_INDEX', '')
os.environ.pop('GTEST_TOTAL_SHARDS', '')
示例9: load
def load(cls, data):
out = super(SavedState, cls).load(data)
if out.isolate_file:
out.isolate_file = trace_inputs.get_native_path_case(out.isolate_file)
return out