summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-06 17:39:48 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-06 17:39:48 +0900
commit4427d830e124879d7a0deb7a098ceabbd1a881ce (patch)
tree4ba2da77985ef7ea94dde4927d07d5b30f7455fc
parent390232ee6d96976e0330412e9cb26b7311390dc9 (diff)
downloadbuildstream-4427d830e124879d7a0deb7a098ceabbd1a881ce.tar.gz
test/utils/savefile.py: Stringify the tmpdir so that tests work.fix-savefile-test-broken
It looks like this newly added test assumes the user has a very recent version of pytest, which supports treating the `tmpdir` fixture like a string. A reasonable alternative to this patch would be require at minimum a version of pytest which supports this newly introduced API.
-rw-r--r--tests/utils/savefile.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/utils/savefile.py b/tests/utils/savefile.py
index 87f9f4b0a..0731f7bea 100644
--- a/tests/utils/savefile.py
+++ b/tests/utils/savefile.py
@@ -5,17 +5,17 @@ from buildstream.utils import save_file_atomic
def test_save_new_file(tmpdir):
- filename = os.path.join(tmpdir, 'savefile-success.test')
+ filename = os.path.join(str(tmpdir), 'savefile-success.test')
with save_file_atomic(filename, 'w') as f:
f.write('foo\n')
- assert os.listdir(tmpdir) == ['savefile-success.test']
+ assert os.listdir(str(tmpdir)) == ['savefile-success.test']
with open(filename) as f:
assert f.read() == 'foo\n'
def test_save_over_existing_file(tmpdir):
- filename = os.path.join(tmpdir, 'savefile-overwrite.test')
+ filename = os.path.join(str(tmpdir), 'savefile-overwrite.test')
with open(filename, 'w') as f:
f.write('existing contents\n')
@@ -23,24 +23,24 @@ def test_save_over_existing_file(tmpdir):
with save_file_atomic(filename, 'w') as f:
f.write('overwritten contents\n')
- assert os.listdir(tmpdir) == ['savefile-overwrite.test']
+ assert os.listdir(str(tmpdir)) == ['savefile-overwrite.test']
with open(filename) as f:
assert f.read() == 'overwritten contents\n'
def test_exception_new_file(tmpdir):
- filename = os.path.join(tmpdir, 'savefile-exception.test')
+ filename = os.path.join(str(tmpdir), 'savefile-exception.test')
with pytest.raises(RuntimeError):
with save_file_atomic(filename, 'w') as f:
f.write('Some junk\n')
raise RuntimeError("Something goes wrong")
- assert os.listdir(tmpdir) == []
+ assert os.listdir(str(tmpdir)) == []
def test_exception_existing_file(tmpdir):
- filename = os.path.join(tmpdir, 'savefile-existing.test')
+ filename = os.path.join(str(tmpdir), 'savefile-existing.test')
with open(filename, 'w') as f:
f.write('existing contents\n')
@@ -50,13 +50,13 @@ def test_exception_existing_file(tmpdir):
f.write('Some junk\n')
raise RuntimeError("Something goes wrong")
- assert os.listdir(tmpdir) == ['savefile-existing.test']
+ assert os.listdir(str(tmpdir)) == ['savefile-existing.test']
with open(filename) as f:
assert f.read() == 'existing contents\n'
def test_attributes(tmpdir):
- filename = os.path.join(tmpdir, 'savefile-attributes.test')
+ filename = os.path.join(str(tmpdir), 'savefile-attributes.test')
with save_file_atomic(filename, 'w') as f:
assert f.real_filename == filename
assert f.name != filename