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/local.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/local.py')
-rw-r--r-- | tests/sources/local.py | 18 |
1 files changed, 9 insertions, 9 deletions
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') |