Skip to content

Commit d151047

Browse files
committed
Adjust test file paths
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent d7fd444 commit d151047

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

tests/test_archive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
- password-protected when supported
5858
"""
5959

60+
project_root = os.path.dirname(os.path.dirname(__file__))
6061

6162
class TestGetExtractorTest(BaseArchiveTestCase):
6263

@@ -287,13 +288,13 @@ def test_7zip_extract_can_extract_to_relative_paths(self):
287288
# The setup is a tad complex because we want to have a relative dir
288289
# to the base dir where we run tests from, i.e. the git checkout dir.
289290
# To use relative paths, we use our tmp dir at the root of the code tree
290-
from os.path import dirname, join, abspath
291+
from os.path import join, abspath
291292
import tempfile
292293
import shutil
293294
from extractcode.sevenzip import extract
294295

295296
test_file = self.get_test_loc('archive/relative_path/basic.zip', copy=True)
296-
project_root = dirname(dirname(dirname(__file__)))
297+
297298
project_tmp = join(project_root, 'tmp')
298299
fileutils.create_dir(project_tmp)
299300
project_root_abs = abspath(project_root)
@@ -1648,15 +1649,14 @@ def test_extract_twice_can_extract_to_relative_paths(self):
16481649
# The setup is a tad complex because we want to have a relative dir
16491650
# to the base dir where we run tests from, i.e. the git checkout dir
16501651
# To use relative paths, we use our tmp dir at the root of the code tree
1651-
from os.path import dirname, join, abspath, exists
1652+
from os.path import join, abspath, exists
16521653
import shutil
16531654
import tempfile
16541655

16551656
test_file = self.get_test_loc('archive/rpm/xz-compressed-cpio.rpm')
16561657
# this will return an extractor that extracts twice
16571658
extractor = archive.get_extractor(test_file)
16581659

1659-
project_root = dirname(dirname(dirname(__file__)))
16601660
project_tmp = join(project_root, 'tmp')
16611661
fileutils.create_dir(project_tmp)
16621662
project_root_abs = abspath(project_root)

tests/test_extract.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
from extractcode_assert_utils import check_no_error
3838
from extractcode_assert_utils import BaseArchiveTestCase
3939

40+
project_root = os.path.dirname(os.path.dirname(__file__))
41+
4042

4143
class TestExtract(BaseArchiveTestCase):
4244
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
@@ -789,11 +791,10 @@ def test_extract_can_extract_to_relative_paths(self):
789791
# The setup is a tad complex because we want to have a relative dir
790792
# to the base dir where we run tests from, i.e. the git checkout dir
791793
# To use relative paths, we use our tmp dir at the root of the code tree
792-
from os.path import dirname, join, abspath
794+
from os.path import join, abspath
793795
import shutil
794796
import tempfile
795797

796-
project_root = dirname(dirname(dirname(__file__)))
797798
project_tmp = join(project_root, 'tmp')
798799
fileutils.create_dir(project_tmp)
799800
project_root_abs = abspath(project_root)

tests/test_extractcode_cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
test_env = FileDrivenTesting()
3737
test_env.test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
38+
project_root = os.path.dirname(os.path.dirname(__file__))
39+
3840

3941
"""
4042
These CLI tests are dependent on py.test monkeypatch to ensure we are testing
@@ -86,14 +88,13 @@ def test_extractcode_command_works_with_relative_paths(monkeypatch):
8688
# The setup is a tad complex because we want to have a relative dir
8789
# to the base dir where we run tests from, i.e. the git checkout dir
8890
# To use relative paths, we use our tmp dir at the root of the code tree
89-
from os.path import dirname, join, abspath
91+
from os.path import join, abspath
9092
from commoncode import fileutils
9193
import extractcode
9294
import tempfile
9395
import shutil
9496

9597
try:
96-
project_root = dirname(dirname(dirname(__file__)))
9798
project_tmp = join(project_root, 'tmp')
9899
fileutils.create_dir(project_tmp)
99100
project_root_abs = abspath(project_root)
@@ -121,13 +122,12 @@ def test_extractcode_command_works_with_relative_paths_verbose(monkeypatch):
121122
# The setup is a tad complex because we want to have a relative dir
122123
# to the base dir where we run tests from, i.e. the git checkout dir
123124
# To use relative paths, we use our tmp dir at the root of the code tree
124-
from os.path import dirname, join, abspath
125+
from os.path import join, abspath
125126
from commoncode import fileutils
126127
import tempfile
127128
import shutil
128129

129130
try:
130-
project_root = dirname(dirname(dirname(__file__)))
131131
project_tmp = join(project_root, 'tmp')
132132
fileutils.create_dir(project_tmp)
133133
project_root_abs = abspath(project_root)

tests/test_libarchive2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
2020
#
21+
import os
2122

2223
from commoncode import fileutils
2324

2425
from extractcode_assert_utils import check_files
2526
from extractcode_assert_utils import BaseArchiveTestCase
2627

28+
project_root = os.path.dirname(os.path.dirname(__file__))
29+
2730
"""
2831
Minimal smoke tests for libarchive2.
2932
"""
@@ -35,13 +38,12 @@ def test_libarchive_extract_can_extract_to_relative_paths(self):
3538
# The setup is a tad complex because we want to have a relative dir
3639
# to the base dir where we run tests from, i.e. the git checkout dir
3740
# To use relative paths, we use our tmp dir at the root of the code tree
38-
from os.path import dirname, join, abspath
41+
from os.path import join, abspath
3942
import tempfile
4043
import shutil
4144
from extractcode.libarchive2 import extract
4245

4346
test_file = self.get_test_loc('archive/relative_path/basic.zip')
44-
project_root = dirname(dirname(dirname(__file__)))
4547
project_tmp = join(project_root, 'tmp')
4648
fileutils.create_dir(project_tmp)
4749
project_root_abs = abspath(project_root)

0 commit comments

Comments
 (0)