summaryrefslogtreecommitdiff
path: root/tests/format
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-20 11:06:42 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-21 14:57:31 +0000
commitf2b15d86debd32241228f7b728016ed0057cd0d2 (patch)
treee98e085e4f0a9020725aa3a25df7809a96d807ba /tests/format
parentbc1b971e169f2fc721c61276c071640caee6a3f8 (diff)
downloadbuildstream-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/format')
-rw-r--r--tests/format/assertion.py2
-rw-r--r--tests/format/project.py10
-rw-r--r--tests/format/variables.py8
3 files changed, 10 insertions, 10 deletions
diff --git a/tests/format/assertion.py b/tests/format/assertion.py
index 8e112658f..cfab105b6 100644
--- a/tests/format/assertion.py
+++ b/tests/format/assertion.py
@@ -23,7 +23,7 @@ DATA_DIR = os.path.join(
('ordered-assertion.bst', 'True', 'True', "It's not horsy time yet"),
])
def test_assertion_cli(cli, datafiles, target, opt_pony, opt_horsy, assertion):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, silent=True, args=[
'--option', 'pony', opt_pony,
'--option', 'horsy', opt_horsy,
diff --git a/tests/format/project.py b/tests/format/project.py
index 031c5540a..b9b5898be 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -19,7 +19,7 @@ DATA_DIR = os.path.join(
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_missing_project_conf(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['workspace', 'list'])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_PROJECT_CONF)
@@ -124,7 +124,7 @@ def test_project_unsupported(cli, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'element-path'))
def test_missing_element_path_directory(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['workspace', 'list'])
result.assert_main_error(ErrorDomain.LOAD,
LoadErrorReason.MISSING_FILE)
@@ -132,7 +132,7 @@ def test_missing_element_path_directory(cli, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'element-path'))
def test_element_path_not_a_directory(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
path = os.path.join(project, 'elements')
for _file_type in filetypegenerator.generate_file_types(path):
result = cli.run(project=project, args=['workspace', 'list'])
@@ -145,7 +145,7 @@ def test_element_path_not_a_directory(cli, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
def test_missing_local_plugin_directory(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['workspace', 'list'])
result.assert_main_error(ErrorDomain.LOAD,
LoadErrorReason.MISSING_FILE)
@@ -153,7 +153,7 @@ def test_missing_local_plugin_directory(cli, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
def test_local_plugin_not_directory(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
path = os.path.join(project, 'plugins')
for _file_type in filetypegenerator.generate_file_types(path):
result = cli.run(project=project, args=['workspace', 'list'])
diff --git a/tests/format/variables.py b/tests/format/variables.py
index 928ad24ec..fe8d8ae8a 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -43,7 +43,7 @@ def print_warning(msg):
])
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'defaults'))
def test_defaults(cli, datafiles, target, varname, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, silent=True, args=[
'show', '--deps', 'none', '--format', '%{vars}', target
])
@@ -69,7 +69,7 @@ def test_defaults(cli, datafiles, target, varname, expected):
])
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'overrides'))
def test_overrides(cli, datafiles, target, varname, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, silent=True, args=[
'show', '--deps', 'none', '--format', '%{vars}', target
])
@@ -80,7 +80,7 @@ def test_overrides(cli, datafiles, target, varname, expected):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'missing_variables'))
def test_missing_variable(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, silent=True, args=[
'show', '--deps', 'none', '--format', '%{config}', 'manual.bst'
])
@@ -93,7 +93,7 @@ def test_missing_variable(cli, datafiles):
def test_cyclic_variables(cli, datafiles):
print_warning("Performing cyclic test, if this test times out it will " +
"exit the test sequence")
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, silent=True, args=[
"build", "cyclic.bst"
])