Skip to content

Commit b0725f9

Browse files
committed
Remove scancode refs that are not needed #2233
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent ea3e944 commit b0725f9

File tree

4 files changed

+43
-42
lines changed

4 files changed

+43
-42
lines changed

tests/extractcode/test_archive.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,20 @@ def test_no_handler_is_selected_for_a_non_archive3(self):
298298

299299
def test_7zip_extract_can_extract_to_relative_paths(self):
300300
# The setup is a tad complex because we want to have a relative dir
301-
# to the base dir where we run tests from, ie the scancode-toolkit/ dir
301+
# to the base dir where we run tests from, i.e. the git checkout dir.
302302
# To use relative paths, we use our tmp dir at the root of the code tree
303303
from os.path import dirname, join, abspath
304304
import tempfile
305305
import shutil
306306
from extractcode.sevenzip import extract
307307

308308
test_file = self.get_test_loc('archive/relative_path/basic.zip', copy=True)
309-
scancode_root = dirname(dirname(dirname(__file__)))
310-
scancode_tmp = join(scancode_root, 'tmp')
311-
fileutils.create_dir(scancode_tmp)
312-
scancode_root_abs = abspath(scancode_root)
313-
test_src_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
314-
test_tgt_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
309+
project_root = dirname(dirname(dirname(__file__)))
310+
project_tmp = join(project_root, 'tmp')
311+
fileutils.create_dir(project_tmp)
312+
project_root_abs = abspath(project_root)
313+
test_src_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
314+
test_tgt_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
315315
shutil.copy(test_file, test_src_dir)
316316
test_src_file = join(test_src_dir, 'basic.zip')
317317
result = list(extract(test_src_file, test_tgt_dir))
@@ -1702,7 +1702,7 @@ def test_extract_twice_with_rpm_with_xz_compressed_cpio(self):
17021702

17031703
def test_extract_twice_can_extract_to_relative_paths(self):
17041704
# The setup is a tad complex because we want to have a relative dir
1705-
# to the base dir where we run tests from, ie the scancode-toolkit/ dir
1705+
# to the base dir where we run tests from, i.e. the git checkout dir
17061706
# To use relative paths, we use our tmp dir at the root of the code tree
17071707
from os.path import dirname, join, abspath, exists
17081708
import shutil
@@ -1712,12 +1712,12 @@ def test_extract_twice_can_extract_to_relative_paths(self):
17121712
# this will return an extractor that extracts twice
17131713
extractor = archive.get_extractor(test_file)
17141714

1715-
scancode_root = dirname(dirname(dirname(__file__)))
1716-
scancode_tmp = join(scancode_root, 'tmp')
1717-
fileutils.create_dir(scancode_tmp)
1718-
scancode_root_abs = abspath(scancode_root)
1719-
test_src_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
1720-
test_tgt_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
1715+
project_root = dirname(dirname(dirname(__file__)))
1716+
project_tmp = join(project_root, 'tmp')
1717+
fileutils.create_dir(project_tmp)
1718+
project_root_abs = abspath(project_root)
1719+
test_src_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
1720+
test_tgt_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
17211721
shutil.copy(test_file, test_src_dir)
17221722
test_src_file = join(test_src_dir, 'xz-compressed-cpio.rpm')
17231723

tests/extractcode/test_extract.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -795,20 +795,21 @@ def test_walk_can_be_extended_while_walking(self):
795795

796796
def test_extract_can_extract_to_relative_paths(self):
797797
# The setup is a tad complex because we want to have a relative dir
798-
# to the base dir where we run tests from, ie the scancode-toolkit/ dir
798+
# to the base dir where we run tests from, i.e. the git checkout dir
799799
# To use relative paths, we use our tmp dir at the root of the code tree
800800
from os.path import dirname, join, abspath
801-
scancode_root = dirname(dirname(dirname(__file__)))
802-
scancode_tmp = join(scancode_root, 'tmp')
803-
fileutils.create_dir(scancode_tmp)
804-
scancode_root_abs = abspath(scancode_root)
801+
import shutil
805802
import tempfile
806-
test_src_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
803+
804+
project_root = dirname(dirname(dirname(__file__)))
805+
project_tmp = join(project_root, 'tmp')
806+
fileutils.create_dir(project_tmp)
807+
project_root_abs = abspath(project_root)
808+
test_src_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
807809
test_file = self.get_test_loc('extract/relative_path/basic.zip')
808-
import shutil
809810
shutil.copy(test_file, test_src_dir)
810811
test_src_file = join(test_src_dir, 'basic.zip')
811-
test_tgt_dir = join(scancode_root, test_src_file) + extractcode.EXTRACT_SUFFIX
812+
test_tgt_dir = join(project_root, test_src_file) + extractcode.EXTRACT_SUFFIX
812813
result = list(extract.extract(test_src_file))
813814
expected = ['c/a/a.txt', 'c/b/a.txt', 'c/c/a.txt']
814815
check_files(test_tgt_dir, expected)

tests/extractcode/test_extractcode_cli.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_extractcode_command_always_shows_something_if_not_using_a_tty_verbose_o
9696

9797
def test_extractcode_command_works_with_relative_paths(monkeypatch):
9898
# The setup is a tad complex because we want to have a relative dir
99-
# to the base dir where we run tests from, ie the scancode-toolkit/ dir
99+
# to the base dir where we run tests from, i.e. the git checkout dir
100100
# To use relative paths, we use our tmp dir at the root of the code tree
101101
from os.path import dirname, join, abspath
102102
from commoncode import fileutils
@@ -105,15 +105,15 @@ def test_extractcode_command_works_with_relative_paths(monkeypatch):
105105
import shutil
106106

107107
try:
108-
scancode_root = dirname(dirname(dirname(__file__)))
109-
scancode_tmp = join(scancode_root, 'tmp')
110-
fileutils.create_dir(scancode_tmp)
111-
scancode_root_abs = abspath(scancode_root)
112-
test_src_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
108+
project_root = dirname(dirname(dirname(__file__)))
109+
project_tmp = join(project_root, 'tmp')
110+
fileutils.create_dir(project_tmp)
111+
project_root_abs = abspath(project_root)
112+
test_src_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
113113
test_file = test_env.get_test_loc('cli/extract_relative_path/basic.zip')
114114
shutil.copy(test_file, test_src_dir)
115115
test_src_file = join(test_src_dir, 'basic.zip')
116-
test_tgt_dir = join(scancode_root, test_src_file) + extractcode.EXTRACT_SUFFIX
116+
test_tgt_dir = join(project_root, test_src_file) + extractcode.EXTRACT_SUFFIX
117117

118118
runner = CliRunner()
119119
monkeypatch.setattr(click._termui_impl, 'isatty', lambda _: True)
@@ -131,19 +131,19 @@ def test_extractcode_command_works_with_relative_paths(monkeypatch):
131131

132132
def test_extractcode_command_works_with_relative_paths_verbose(monkeypatch):
133133
# The setup is a tad complex because we want to have a relative dir
134-
# to the base dir where we run tests from, ie the scancode-toolkit/ dir
134+
# to the base dir where we run tests from, i.e. the git checkout dir
135135
# To use relative paths, we use our tmp dir at the root of the code tree
136136
from os.path import dirname, join, abspath
137137
from commoncode import fileutils
138138
import tempfile
139139
import shutil
140140

141141
try:
142-
scancode_root = dirname(dirname(dirname(__file__)))
143-
scancode_tmp = join(scancode_root, 'tmp')
144-
fileutils.create_dir(scancode_tmp)
145-
scancode_root_abs = abspath(scancode_root)
146-
test_src_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
142+
project_root = dirname(dirname(dirname(__file__)))
143+
project_tmp = join(project_root, 'tmp')
144+
fileutils.create_dir(project_tmp)
145+
project_root_abs = abspath(project_root)
146+
test_src_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
147147
test_file = test_env.get_test_loc('cli/extract_relative_path/basic.zip')
148148
shutil.copy(test_file, test_src_dir)
149149
test_src_file = join(test_src_dir, 'basic.zip')

tests/extractcode/test_libarchive2.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ class TestExtractorTest(BaseArchiveTestCase):
4040

4141
def test_libarchive_extract_can_extract_to_relative_paths(self):
4242
# The setup is a tad complex because we want to have a relative dir
43-
# to the base dir where we run tests from, ie the scancode-toolkit/ dir
43+
# to the base dir where we run tests from, i.e. the git checkout dir
4444
# To use relative paths, we use our tmp dir at the root of the code tree
4545
from os.path import dirname, join, abspath
4646
import tempfile
4747
import shutil
4848
from extractcode.libarchive2 import extract
4949

5050
test_file = self.get_test_loc('archive/relative_path/basic.zip')
51-
scancode_root = dirname(dirname(dirname(__file__)))
52-
scancode_tmp = join(scancode_root, 'tmp')
53-
fileutils.create_dir(scancode_tmp)
54-
scancode_root_abs = abspath(scancode_root)
55-
test_src_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
56-
test_tgt_dir = tempfile.mkdtemp(dir=scancode_tmp).replace(scancode_root_abs, '').strip('\\/')
51+
project_root = dirname(dirname(dirname(__file__)))
52+
project_tmp = join(project_root, 'tmp')
53+
fileutils.create_dir(project_tmp)
54+
project_root_abs = abspath(project_root)
55+
test_src_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
56+
test_tgt_dir = tempfile.mkdtemp(dir=project_tmp).replace(project_root_abs, '').strip('\\/')
5757
shutil.copy(test_file, test_src_dir)
5858
test_src_file = join(test_src_dir, 'basic.zip')
5959
result = list(extract(test_src_file, test_tgt_dir))

0 commit comments

Comments
 (0)