Skip to content

Commit bb148ea

Browse files
Fix test failures
Signed-off-by: Ayan Sinha Mahapatra <asmahapatra@aboutcode.org>
1 parent 72dd3d8 commit bb148ea

6 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/commoncode/resource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,8 +1667,8 @@ def strip_first_path_segment(path):
16671667
''
16681668
>>> strip_first_path_segment('foo/bar/baz')
16691669
'bar/baz'
1670-
>>> strip_first_path_segment('/foo/bar/baz/')
1671-
'bar/baz'
1670+
>>> strip_first_path_segment('/foo/bar/baz')
1671+
'foo/bar/baz'
16721672
>>> strip_first_path_segment('foo/')
16731673
''
16741674
"""

src/commoncode/testcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def get_test_loc(self, test_path, copy=False, debug=False, must_exist=True, rela
132132

133133
if relative:
134134
_, _, rel_test_loc = test_loc.rpartition(os.getcwd())
135-
return rel_test_loc.strip("/")
135+
return rel_test_loc.strip("/").strip("\\")
136136

137137
return test_loc
138138

src/scancode/outdated.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ def total_seconds(td):
8383

8484
class VersionCheckState:
8585

86-
def __init__(self):
86+
def __init__(self, is_test=False):
87+
if is_test:
88+
self.state={}
89+
return
90+
8791
self.statefile_path = os.path.join(
8892
scancode_cache_dir, 'scancode-version-check.json')
8993
self.lockfile_path = self.statefile_path + '.lockfile'
@@ -135,6 +139,7 @@ def check_scancode_version(
135139
release_date=scancode_release_date,
136140
new_version_url='https://pypi.org/pypi/scancode-toolkit/json',
137141
force=False,
142+
is_test=False,
138143
):
139144
"""
140145
Check for an updated version of scancode-toolkit. Return a message to
@@ -146,6 +151,7 @@ def check_scancode_version(
146151
installed_version=installed_version,
147152
new_version_url=new_version_url,
148153
force=force,
154+
is_test=is_test,
149155
)
150156
if newer_version:
151157
return build_outdated_message(
@@ -159,6 +165,7 @@ def fetch_newer_version(
159165
installed_version=scancode_version,
160166
new_version_url='https://pypi.org/pypi/scancode-toolkit/json',
161167
force=False,
168+
is_test=False,
162169
):
163170
"""
164171
Return a version string if there is an updated version of scancode-toolkit
@@ -175,9 +182,10 @@ def fetch_newer_version(
175182

176183
try:
177184
installed_version = packaging_version.parse(installed_version)
178-
state = VersionCheckState()
185+
state = VersionCheckState(is_test=is_test)
179186

180187
current_time = datetime.datetime.utcnow()
188+
latest_version = None
181189
# Determine if we need to refresh the state
182190
if ('last_check' in state.state and 'latest_version' in state.state):
183191
last_check = datetime.datetime.strptime(

src/scancode_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _create_dir(location):
9595
from subprocess import CalledProcessError
9696

9797
# this may fail with exceptions
98-
cmd = 'git', 'describe', '--tags',
98+
cmd = 'git', 'describe', '--tags', '--match="v*"'
9999
try:
100100
output = check_output(cmd, stderr=STDOUT)
101101
__version__ = output.decode('utf-8').strip()

tests/scancode/data/help/help.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ Options:
9292
such that all paths have a common root directory.
9393

9494
pre-scan:
95-
--ignore <pattern> Ignore files matching <pattern>.
96-
--include <pattern> Include files matching <pattern>.
9795
--facet <facet>=<pattern> Add the <facet> to files with a path matching
9896
<pattern>.
9997

@@ -138,6 +136,7 @@ Options:
138136
which are todo items and needs manual review.
139137

140138
core:
139+
--ignore <pattern> Ignore files matching <pattern>.
141140
--timeout <seconds> Stop an unfinished file scan after a timeout in
142141
seconds. [default: 120 seconds]
143142
-n, --processes INT Set the number of parallel processes to use. Disable

tests/scancode/test_outdated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def jget(*args, **kwargs):
152152
json=jget,
153153
status_code=200
154154
)
155-
assert not outdated.fetch_newer_version(force=True)
156-
assert not outdated.check_scancode_version(force=True)
155+
assert not outdated.fetch_newer_version(force=True, is_test=True)
156+
assert not outdated.check_scancode_version(force=True, is_test=True)
157157

158158

159159
def test_fetch_newer_version_local_git_version():

0 commit comments

Comments
 (0)