Skip to content

Commit 2cc515a

Browse files
committed
Add arg to testcase.get_test_loc to skip file existence check
* no behavior change otherwise, and the new arg is True by default. Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 185675b commit 2cc515a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/commoncode/testcase.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015 nexB Inc. and others. All rights reserved.
2+
# Copyright (c) 2017 nexB Inc. and others. All rights reserved.
33
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
44
# The ScanCode software is licensed under the Apache License version 2.0.
55
# Data generated with ScanCode require an acknowledgment.
@@ -22,6 +22,9 @@
2222
# ScanCode is a free software code scanning tool from nexB Inc. and others.
2323
# Visit https://github.com/nexB/scancode-toolkit/ for support and download.
2424

25+
"""
26+
FIXME: TEMPORARY COPY of commoncode.testcase to handle new semantics for get_test_loc
27+
"""
2528

2629
from __future__ import absolute_import
2730
from __future__ import print_function
@@ -92,7 +95,7 @@ def to_os_native_path(path):
9295
return path
9396

9497

95-
def get_test_loc(test_path, test_data_dir, debug=False):
98+
def get_test_loc(test_path, test_data_dir, debug=False, exists=True):
9699
"""
97100
Given a `test_path` relative to the `test_data_dir` directory, return the
98101
location to a test file or directory for this path. No copy is done.
@@ -112,7 +115,7 @@ def get_test_loc(test_path, test_data_dir, debug=False):
112115
tpath = to_os_native_path(test_path)
113116
test_loc = os.path.abspath(os.path.join(test_data_dir, tpath))
114117

115-
if not os.path.exists(test_loc):
118+
if exists and not os.path.exists(test_loc):
116119
raise IOError("[Errno 2] No such file or directory: "
117120
"test_path not found: '%(test_loc)s'" % locals())
118121

0 commit comments

Comments
 (0)