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/git.py | |
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/git.py')
-rw-r--r-- | tests/sources/git.py | 32 |
1 files changed, 16 insertions, 16 deletions
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)) |