Make test_ringbuilder less brittle
If one has an object.builder file in the current directory and runs test_ringbuilder, it will fail with an irritating error. That's because test_use_ringfile_as_builderfile doesn't use self.tmpfile, but object.builder - and that one might exist in the local directory. This patch changes this, using self.tmpfile as argument name. Closes-Bug: 1590356 Change-Id: I4b3287a36e8a5e469eb037128427dc7867910e53
This commit is contained in:
parent
ca86cb3606
commit
f6b0b75a25
@ -1925,14 +1925,18 @@ class TestCommands(unittest.TestCase, RunSwiftRingBuilderMixin):
|
||||
mock_stdout = six.StringIO()
|
||||
mock_stderr = six.StringIO()
|
||||
|
||||
argv = ["", "object.ring.gz"]
|
||||
argv = ["", self.tmpfile, "rebalance", "3"],
|
||||
self.assertSystemExit(EXIT_SUCCESS, ringbuilder.main, argv)
|
||||
|
||||
argv = ["", "%s.ring.gz" % self.tmpfile]
|
||||
|
||||
with mock.patch("sys.stdout", mock_stdout):
|
||||
with mock.patch("sys.stderr", mock_stderr):
|
||||
self.assertSystemExit(EXIT_ERROR, ringbuilder.main, argv)
|
||||
expected = "Note: using object.builder instead of object.ring.gz " \
|
||||
expected = "Note: using %s.builder instead of %s.ring.gz " \
|
||||
"as builder file\n" \
|
||||
"Ring Builder file does not exist: object.builder\n"
|
||||
"Ring Builder file does not exist: %s.builder\n" % (
|
||||
self.tmpfile, self.tmpfile, self.tmpfile)
|
||||
self.assertEqual(expected, mock_stdout.getvalue())
|
||||
|
||||
def test_main_no_arguments(self):
|
||||
|
Loading…
Reference in New Issue
Block a user