diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-03-20 11:06:42 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-21 14:57:31 +0000 |
commit | f2b15d86debd32241228f7b728016ed0057cd0d2 (patch) | |
tree | e98e085e4f0a9020725aa3a25df7809a96d807ba /tests/sources | |
parent | bc1b971e169f2fc721c61276c071640caee6a3f8 (diff) | |
download | buildstream-f2b15d86debd32241228f7b728016ed0057cd0d2.tar.gz |
tests: str(datafiles) instead of a longer thing
Replace some popular copypasta.
This important-looking invocation:
os.path.join(datafiles.dirname, datafiles.basename)
is equivalent to this shorter invocation:
project = str(datafiles)
It seems like it's very popular copypasta, replace it with the shorter
one thus:
# Use 'gsed' or 'sed' etc. as appropriate for your system.
git config --global alias.sub '!f() { git grep --name-only --null "$1" | gxargs --null gsed --in-place --expression "s/$1/$2/g" ; }; f'
git sub 'os.path.join(datafiles.dirname, datafiles.basename)' 'str(datafiles)'
Diffstat (limited to 'tests/sources')
-rw-r--r-- | tests/sources/bzr.py | 2 | ||||
-rw-r--r-- | tests/sources/deb.py | 14 | ||||
-rw-r--r-- | tests/sources/generic/build_checkout.py | 2 | ||||
-rw-r--r-- | tests/sources/generic/fetch.py | 2 | ||||
-rw-r--r-- | tests/sources/generic/track.py | 14 | ||||
-rw-r--r-- | tests/sources/generic/workspace.py | 4 | ||||
-rw-r--r-- | tests/sources/git.py | 32 | ||||
-rw-r--r-- | tests/sources/local.py | 18 | ||||
-rw-r--r-- | tests/sources/no_fetch_cached.py | 2 | ||||
-rw-r--r-- | tests/sources/ostree.py | 2 | ||||
-rw-r--r-- | tests/sources/patch.py | 20 | ||||
-rw-r--r-- | tests/sources/pip.py | 6 | ||||
-rw-r--r-- | tests/sources/previous_source_access.py | 2 | ||||
-rw-r--r-- | tests/sources/remote.py | 14 | ||||
-rw-r--r-- | tests/sources/tar.py | 22 | ||||
-rw-r--r-- | tests/sources/zip.py | 14 |
16 files changed, 85 insertions, 85 deletions
diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py index a76814a30..0a3c345bd 100644 --- a/tests/sources/bzr.py +++ b/tests/sources/bzr.py @@ -19,7 +19,7 @@ DATA_DIR = os.path.join( @pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR)) def test_fetch_checkout(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), 'checkout') repo = create_repo('bzr', str(tmpdir)) diff --git a/tests/sources/deb.py b/tests/sources/deb.py index 6e92facf6..2538efe3b 100644 --- a/tests/sources/deb.py +++ b/tests/sources/deb.py @@ -40,7 +40,7 @@ def _copy_deb(start_location, tmpdir): @pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-ref')) def test_no_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) assert cli.get_element_state(project, 'target.bst') == 'no reference' @@ -49,7 +49,7 @@ def test_no_ref(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_fetch_bad_url(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Try to fetch it @@ -64,7 +64,7 @@ def test_fetch_bad_url(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_fetch_bad_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Copy test deb to tmpdir @@ -82,7 +82,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_track_warning(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Copy test deb to tmpdir @@ -100,7 +100,7 @@ def test_track_warning(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_stage_default_basedir(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -128,7 +128,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-basedir')) def test_stage_no_basedir(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -156,7 +156,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'explicit-basedir')) def test_stage_explicit_basedir(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") diff --git a/tests/sources/generic/build_checkout.py b/tests/sources/generic/build_checkout.py index f2dee6c60..e113b40cb 100644 --- a/tests/sources/generic/build_checkout.py +++ b/tests/sources/generic/build_checkout.py @@ -46,7 +46,7 @@ def strict_args(args, strict): @pytest.mark.parametrize("strict,kind", fetch_build_checkout_combos) def test_fetch_build_checkout(cli, tmpdir, datafiles, strict, kind): checkout = os.path.join(cli.directory, 'checkout') - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) dev_files_path = os.path.join(project, 'files', 'dev-files') element_path = os.path.join(project, 'elements') element_name = 'build-test-{}.bst'.format(kind) diff --git a/tests/sources/generic/fetch.py b/tests/sources/generic/fetch.py index 3c7a28182..f5931f8f1 100644 --- a/tests/sources/generic/fetch.py +++ b/tests/sources/generic/fetch.py @@ -37,7 +37,7 @@ DATA_DIR = os.path.join(TOP_DIR, 'project') @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_fetch(cli, tmpdir, datafiles, kind): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) bin_files_path = os.path.join(project, 'files', 'bin-files') element_path = os.path.join(project, 'elements') element_name = 'fetch-test-{}.bst'.format(kind) diff --git a/tests/sources/generic/track.py b/tests/sources/generic/track.py index 76956fcdb..4726a453e 100644 --- a/tests/sources/generic/track.py +++ b/tests/sources/generic/track.py @@ -52,7 +52,7 @@ def generate_element(repo, element_path, dep_name=None): @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_track(cli, tmpdir, datafiles, ref_storage, kind): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) dev_files_path = os.path.join(project, 'files', 'dev-files') element_path = os.path.join(project, 'elements') element_name = 'track-test-{}.bst'.format(kind) @@ -112,7 +112,7 @@ def test_track(cli, tmpdir, datafiles, ref_storage, kind): @pytest.mark.parametrize("amount", [(1), (10)]) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_track_recurse(cli, tmpdir, datafiles, kind, amount): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) dev_files_path = os.path.join(project, 'files', 'dev-files') element_path = os.path.join(project, 'elements') @@ -176,7 +176,7 @@ def test_track_recurse(cli, tmpdir, datafiles, kind, amount): @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_track_recurse_except(cli, tmpdir, datafiles, kind): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) dev_files_path = os.path.join(project, 'files', 'dev-files') element_path = os.path.join(project, 'elements') element_dep_name = 'track-test-dep-{}.bst'.format(kind) @@ -223,7 +223,7 @@ def test_track_recurse_except(cli, tmpdir, datafiles, kind): @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_cross_junction(cli, tmpdir, datafiles, ref_storage, kind): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) subproject_path = os.path.join(project, 'files', 'sub-project') junction_path = os.path.join(project, 'elements', 'junction.bst') etc_files = os.path.join(subproject_path, 'files', 'etc-files') @@ -266,7 +266,7 @@ def test_cross_junction(cli, tmpdir, datafiles, ref_storage, kind): @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_track_include(cli, tmpdir, datafiles, ref_storage, kind): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) dev_files_path = os.path.join(project, 'files', 'dev-files') element_path = os.path.join(project, 'elements') element_name = 'track-test-{}.bst'.format(kind) @@ -329,7 +329,7 @@ def test_track_include(cli, tmpdir, datafiles, ref_storage, kind): @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_track_include_junction(cli, tmpdir, datafiles, ref_storage, kind): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) dev_files_path = os.path.join(project, 'files', 'dev-files') element_path = os.path.join(project, 'elements') element_name = 'track-test-{}.bst'.format(kind) @@ -398,7 +398,7 @@ def test_track_include_junction(cli, tmpdir, datafiles, ref_storage, kind): @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) def test_track_junction_included(cli, tmpdir, datafiles, ref_storage, kind): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) element_path = os.path.join(project, 'elements') subproject_path = os.path.join(project, 'files', 'sub-project') junction_path = os.path.join(element_path, 'junction.bst') diff --git a/tests/sources/generic/workspace.py b/tests/sources/generic/workspace.py index 552981a4f..ad115c1ba 100644 --- a/tests/sources/generic/workspace.py +++ b/tests/sources/generic/workspace.py @@ -40,9 +40,9 @@ class WorkspaceCreator(): self.datafiles = datafiles if not project_path: - project_path = os.path.join(datafiles.dirname, datafiles.basename) + project_path = str(datafiles) else: - shutil.copytree(os.path.join(datafiles.dirname, datafiles.basename), project_path) + shutil.copytree(str(datafiles), project_path) self.project_path = project_path self.bin_files_path = os.path.join(project_path, 'files', 'bin-files') diff --git a/tests/sources/git.py b/tests/sources/git.py index ca22bb2fd..8922a47d7 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -46,7 +46,7 @@ DATA_DIR = os.path.join( @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_fetch_bad_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Create the repo from 'repofiles' subdir repo = create_repo('git', str(tmpdir)) @@ -72,7 +72,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_fetch_checkout(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir @@ -111,7 +111,7 @@ def test_submodule_fetch_checkout(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_fetch_source_enable_explicit(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir @@ -150,7 +150,7 @@ def test_submodule_fetch_source_enable_explicit(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_fetch_source_disable(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir @@ -189,7 +189,7 @@ def test_submodule_fetch_source_disable(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_fetch_submodule_does_override(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir @@ -228,7 +228,7 @@ def test_submodule_fetch_submodule_does_override(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_fetch_submodule_individual_checkout(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir @@ -273,7 +273,7 @@ def test_submodule_fetch_submodule_individual_checkout(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_fetch_submodule_individual_checkout_explicit(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir @@ -318,7 +318,7 @@ def test_submodule_fetch_submodule_individual_checkout_explicit(cli, tmpdir, dat @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'project-override')) def test_submodule_fetch_project_override(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir @@ -357,7 +357,7 @@ def test_submodule_fetch_project_override(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_track_ignore_inconsistent(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Create the repo from 'repofiles' subdir repo = create_repo('git', str(tmpdir)) @@ -394,7 +394,7 @@ def test_submodule_track_ignore_inconsistent(cli, tmpdir, datafiles): @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Create the repo from 'repofiles' subdir repo = create_repo('git', str(tmpdir)) @@ -422,7 +422,7 @@ def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) @pytest.mark.parametrize("fail", ['warn', 'error']) def test_ref_not_in_track(cli, tmpdir, datafiles, fail): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Make the warning an error if we're testing errors if fail == 'error': @@ -465,7 +465,7 @@ def test_ref_not_in_track(cli, tmpdir, datafiles, fail): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) @pytest.mark.parametrize("fail", ['warn', 'error']) def test_unlisted_submodule(cli, tmpdir, datafiles, fail): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Make the warning an error if we're testing errors if fail == 'error': @@ -538,7 +538,7 @@ def test_unlisted_submodule(cli, tmpdir, datafiles, fail): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) @pytest.mark.parametrize("fail", ['warn', 'error']) def test_track_unlisted_submodule(cli, tmpdir, datafiles, fail): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Make the warning an error if we're testing errors if fail == 'error': @@ -601,7 +601,7 @@ def test_track_unlisted_submodule(cli, tmpdir, datafiles, fail): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) @pytest.mark.parametrize("fail", ['warn', 'error']) def test_invalid_submodule(cli, tmpdir, datafiles, fail): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Make the warning an error if we're testing errors if fail == 'error': @@ -673,7 +673,7 @@ def test_invalid_submodule(cli, tmpdir, datafiles, fail): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) @pytest.mark.parametrize("fail", ['warn', 'error']) def test_track_invalid_submodule(cli, tmpdir, datafiles, fail): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Make the warning an error if we're testing errors if fail == 'error': @@ -735,7 +735,7 @@ def test_track_invalid_submodule(cli, tmpdir, datafiles, fail): @pytest.mark.parametrize("ref_format", ['sha1', 'git-describe']) @pytest.mark.parametrize("tag,extra_commit", [(False, False), (True, False), (True, True)]) def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Create the repo from 'repofiles' subdir repo = create_repo('git', str(tmpdir)) diff --git a/tests/sources/local.py b/tests/sources/local.py index b9201bad7..e5f6d4cdf 100644 --- a/tests/sources/local.py +++ b/tests/sources/local.py @@ -16,7 +16,7 @@ DATA_DIR = os.path.join( @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_missing_path(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Removing the local file causes preflight to fail localfile = os.path.join(project, 'file.txt') @@ -30,7 +30,7 @@ def test_missing_path(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_non_regular_file_or_directory(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) localfile = os.path.join(project, 'file.txt') for _file_type in filetypegenerator.generate_file_types(localfile): @@ -48,7 +48,7 @@ def test_non_regular_file_or_directory(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_invalid_absolute_path(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) with open(os.path.join(project, "target.bst"), 'r') as f: old_yaml = f.read() @@ -66,7 +66,7 @@ def test_invalid_absolute_path(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'invalid-relative-path')) def test_invalid_relative_path(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) result = cli.run(project=project, args=['show', 'target.bst']) result.assert_main_error(ErrorDomain.LOAD, @@ -75,7 +75,7 @@ def test_invalid_relative_path(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_stage_file(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Build, checkout @@ -90,7 +90,7 @@ def test_stage_file(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'directory')) def test_stage_directory(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Build, checkout @@ -107,7 +107,7 @@ def test_stage_directory(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'symlink')) def test_stage_symlink(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Workaround datafiles bug: @@ -132,7 +132,7 @@ def test_stage_symlink(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'file-exists')) def test_stage_file_exists(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Build, checkout result = cli.run(project=project, args=['build', 'target.bst']) @@ -142,7 +142,7 @@ def test_stage_file_exists(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'directory')) def test_stage_directory_symlink(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") symlink = os.path.join(project, 'files', 'symlink-to-subdir') diff --git a/tests/sources/no_fetch_cached.py b/tests/sources/no_fetch_cached.py index b7952220d..767c193d2 100644 --- a/tests/sources/no_fetch_cached.py +++ b/tests/sources/no_fetch_cached.py @@ -23,7 +23,7 @@ DATA_DIR = os.path.join( @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(DATA_DIR) def test_no_fetch_cached(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Create the repo from 'files' subdir repo = create_repo('git', str(tmpdir)) diff --git a/tests/sources/ostree.py b/tests/sources/ostree.py index 6b390b5b6..2d4dd953a 100644 --- a/tests/sources/ostree.py +++ b/tests/sources/ostree.py @@ -37,7 +37,7 @@ DATA_DIR = os.path.join( @pytest.mark.datafiles(os.path.join(DATA_DIR, 'template')) def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Create the repo from 'repofiles' subdir repo = create_repo('ostree', str(tmpdir)) diff --git a/tests/sources/patch.py b/tests/sources/patch.py index 3d53c4b14..49c6594dc 100644 --- a/tests/sources/patch.py +++ b/tests/sources/patch.py @@ -16,7 +16,7 @@ DATA_DIR = os.path.join( @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_missing_patch(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Removing the local file causes preflight to fail localfile = os.path.join(project, 'file_1.patch') @@ -30,7 +30,7 @@ def test_missing_patch(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_non_regular_file_patch(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) patch_path = os.path.join(project, 'irregular_file.patch') for _file_type in filetypegenerator.generate_file_types(patch_path): @@ -46,7 +46,7 @@ def test_non_regular_file_patch(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_invalid_absolute_path(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) with open(os.path.join(project, "target.bst"), 'r') as f: old_yaml = f.read() @@ -64,7 +64,7 @@ def test_invalid_absolute_path(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'invalid-relative-path')) def test_invalid_relative_path(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) result = cli.run(project=project, args=['show', 'irregular.bst']) result.assert_main_error(ErrorDomain.LOAD, @@ -73,7 +73,7 @@ def test_invalid_relative_path(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_stage_and_patch(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Build, checkout @@ -89,7 +89,7 @@ def test_stage_and_patch(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_stage_file_nonexistent_dir(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Fails at build time because it tries to patch into a non-existing directory result = cli.run(project=project, args=['build', 'failure-nonexistent-dir.bst']) @@ -99,7 +99,7 @@ def test_stage_file_nonexistent_dir(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) def test_stage_file_empty_dir(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Fails at build time because it tries to patch with nothing else staged result = cli.run(project=project, args=['build', 'failure-empty-dir.bst']) @@ -109,7 +109,7 @@ def test_stage_file_empty_dir(cli, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'separate-patch-dir')) def test_stage_separate_patch_dir(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Track, fetch, build, checkout @@ -125,7 +125,7 @@ def test_stage_separate_patch_dir(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'multiple-patches')) def test_stage_multiple_patches(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Track, fetch, build, checkout @@ -141,7 +141,7 @@ def test_stage_multiple_patches(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'different-strip-level')) def test_patch_strip_level(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") # Track, fetch, build, checkout diff --git a/tests/sources/pip.py b/tests/sources/pip.py index 1d1664bf1..0a0a846ef 100644 --- a/tests/sources/pip.py +++ b/tests/sources/pip.py @@ -23,7 +23,7 @@ def generate_project(project_dir): # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-ref')) def test_no_ref(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project) assert cli.get_element_state(project, 'target.bst') == 'no reference' @@ -31,7 +31,7 @@ def test_no_ref(cli, datafiles): # Test that pip is not allowed to be the first source @pytest.mark.datafiles(os.path.join(DATA_DIR, 'first-source-pip')) def test_first_source(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project) result = cli.run(project=project, args=[ 'show', 'target.bst' @@ -43,7 +43,7 @@ def test_first_source(cli, datafiles): # have been specified @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-packages')) def test_no_packages(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project) result = cli.run(project=project, args=[ 'show', 'target.bst' diff --git a/tests/sources/previous_source_access.py b/tests/sources/previous_source_access.py index cb1c54c27..29d1f3023 100644 --- a/tests/sources/previous_source_access.py +++ b/tests/sources/previous_source_access.py @@ -18,7 +18,7 @@ DATA_DIR = os.path.join( # Test that plugins can access data from previous sources @pytest.mark.datafiles(DATA_DIR) def test_custom_transform_source(cli, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) # Ensure we can track result = cli.run(project=project, args=[ diff --git a/tests/sources/remote.py b/tests/sources/remote.py index f6ea9bf65..2a23895ac 100644 --- a/tests/sources/remote.py +++ b/tests/sources/remote.py @@ -39,7 +39,7 @@ def generate_project_file_server(server, project_dir): # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-ref')) def test_no_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) assert cli.get_element_state(project, 'target.bst') == 'no reference' @@ -48,7 +48,7 @@ def test_no_ref(cli, tmpdir, datafiles): # refers to 'file' but that file is not present. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'missing-file')) def test_missing_file(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Try to fetch it @@ -62,7 +62,7 @@ def test_missing_file(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'path-in-filename')) def test_path_in_filename(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Try to fetch it @@ -76,7 +76,7 @@ def test_path_in_filename(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'single-file')) def test_simple_file_build(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -109,7 +109,7 @@ def test_simple_file_build(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'single-file-custom-name')) def test_simple_file_custom_name_build(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -137,7 +137,7 @@ def test_unique_key(cli, tmpdir, datafiles): '''This test confirms that the 'filename' parameter is honoured when it comes to generating a cache key for the source. ''' - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) states = cli.get_element_states(project, [ 'target.bst', 'target-custom.bst', 'target-custom-executable.bst' @@ -169,7 +169,7 @@ def test_unique_key(cli, tmpdir, datafiles): def test_executable(cli, tmpdir, datafiles): '''This test confirms that the 'ecxecutable' parameter is honoured. ''' - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") assert cli.get_element_state(project, 'target-custom-executable.bst') == "fetch needed" diff --git a/tests/sources/tar.py b/tests/sources/tar.py index ca6806b32..7a516459d 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -68,7 +68,7 @@ def generate_project_file_server(base_url, project_dir): # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-ref')) def test_no_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) assert cli.get_element_state(project, 'target.bst') == 'no reference' @@ -76,7 +76,7 @@ def test_no_ref(cli, tmpdir, datafiles): # Test that when I fetch a nonexistent URL, errors are handled gracefully and a retry is performed. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_fetch_bad_url(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Try to fetch it @@ -91,7 +91,7 @@ def test_fetch_bad_url(cli, tmpdir, datafiles): # Test that when I fetch with an invalid ref, it fails. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_fetch_bad_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Create a local tar @@ -109,7 +109,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): # Test that when tracking with a ref set, there is a warning @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_track_warning(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Create a local tar @@ -128,7 +128,7 @@ def test_track_warning(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_default_basedir(cli, tmpdir, datafiles, srcdir): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -157,7 +157,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles, srcdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-basedir')) @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_no_basedir(cli, tmpdir, datafiles, srcdir): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -186,7 +186,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles, srcdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'explicit-basedir')) @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -215,7 +215,7 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir): # leading paths @pytest.mark.datafiles(os.path.join(DATA_DIR, 'contains-links')) def test_stage_contains_links(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -251,7 +251,7 @@ def test_stage_contains_links(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -280,7 +280,7 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, 'read-only')) def test_read_only_dir(cli, tmpdir, datafiles): try: - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Get the tarball in tests/sources/tar/read-only/content @@ -397,7 +397,7 @@ def test_netrc_already_specified_user(cli, datafiles, server_type, tmpdir): # the netrc module is trying to find it's ~/.netrc file. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_homeless_environment(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Create a local tar diff --git a/tests/sources/zip.py b/tests/sources/zip.py index 3193d38ca..1c86e56d7 100644 --- a/tests/sources/zip.py +++ b/tests/sources/zip.py @@ -53,7 +53,7 @@ def generate_project_file_server(server, project_dir): # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-ref')) def test_no_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) assert cli.get_element_state(project, 'target.bst') == 'no reference' @@ -61,7 +61,7 @@ def test_no_ref(cli, tmpdir, datafiles): # Test that when I fetch a nonexistent URL, errors are handled gracefully and a retry is performed. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_fetch_bad_url(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Try to fetch it @@ -76,7 +76,7 @@ def test_fetch_bad_url(cli, tmpdir, datafiles): # Test that when I fetch with an invalid ref, it fails. @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_fetch_bad_ref(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Create a local tar @@ -94,7 +94,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): # Test that when tracking with a ref set, there is a warning @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_track_warning(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) # Create a local tar @@ -112,7 +112,7 @@ def test_track_warning(cli, tmpdir, datafiles): # Test that a staged checkout matches what was tarred up, with the default first subdir @pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch')) def test_stage_default_basedir(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -140,7 +140,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles): # Test that a staged checkout matches what was tarred up, with an empty base-dir @pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-basedir')) def test_stage_no_basedir(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") @@ -168,7 +168,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles): # Test that a staged checkout matches what was tarred up, with an explicit basedir @pytest.mark.datafiles(os.path.join(DATA_DIR, 'explicit-basedir')) def test_stage_explicit_basedir(cli, tmpdir, datafiles): - project = os.path.join(datafiles.dirname, datafiles.basename) + project = str(datafiles) generate_project(project, tmpdir) checkoutdir = os.path.join(str(tmpdir), "checkout") |