Rev 5645: Backport deprecation, and tests for failIfExists and failUnlessExists in http://bazaar.launchpad.net/~vila/bzr/2.3-integration/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri May 13 10:59:20 UTC 2011
At http://bazaar.launchpad.net/~vila/bzr/2.3-integration/
------------------------------------------------------------
revno: 5645
revision-id: v.ladeuil+lp at free.fr-20110513105920-5mvhsxckddrmbvnf
parent: v.ladeuil+lp at free.fr-20110513105756-puz881ab1ji2w1dj
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 2.3.3-dev
timestamp: Fri 2011-05-13 12:59:20 +0200
message:
Backport deprecation, and tests for failIfExists and failUnlessExists
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2011-05-12 20:26:05 +0000
+++ b/bzrlib/tests/__init__.py 2011-05-13 10:59:20 +0000
@@ -1434,7 +1434,7 @@
def assertFileEqual(self, content, path):
"""Fail if path does not contain 'content'."""
- self.failUnlessExists(path)
+ self.assertPathExists(path)
f = file(path, 'rb')
try:
s = f.read()
@@ -1450,20 +1450,28 @@
else:
self.assertEqual(expected_docstring, obj.__doc__)
+ @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4)))
def failUnlessExists(self, path):
+ return self.assertPathExists(path)
+
+ def assertPathExists(self, path):
"""Fail unless path or paths, which may be abs or relative, exist."""
if not isinstance(path, basestring):
for p in path:
- self.failUnlessExists(p)
+ self.assertPathExists(p)
else:
self.assertTrue(osutils.lexists(path),
path + " does not exist")
+ @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4)))
def failIfExists(self, path):
+ return self.assertPathDoesNotExist(path)
+
+ def assertPathDoesNotExist(self, path):
"""Fail if path or paths, which may be abs or relative, exist."""
if not isinstance(path, basestring):
for p in path:
- self.failIfExists(p)
+ self.assertPathDoesNotExist(p)
else:
self.assertFalse(osutils.lexists(path),
path + " exists")
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2011-05-12 20:26:05 +0000
+++ b/bzrlib/tests/test_selftest.py 2011-05-13 10:59:20 +0000
@@ -512,6 +512,25 @@
self.assertRaises(AssertionError, self.assertEqualStat,
os.lstat("foo"), os.lstat("longname"))
+ def test_failUnlessExists(self):
+ """Deprecated failUnlessExists and failIfExists"""
+ self.applyDeprecated(
+ deprecated_in((2, 4)),
+ self.failUnlessExists, '.')
+ self.build_tree(['foo/', 'foo/bar'])
+ self.applyDeprecated(
+ deprecated_in((2, 4)),
+ self.failUnlessExists, 'foo/bar')
+ self.applyDeprecated(
+ deprecated_in((2, 4)),
+ self.failIfExists, 'foo/foo')
+
+ def test_assertPathExists(self):
+ self.assertPathExists('.')
+ self.build_tree(['foo/', 'foo/bar'])
+ self.assertPathExists('foo/bar')
+ self.assertPathDoesNotExist('foo/foo')
+
class TestTestCaseWithMemoryTransport(tests.TestCaseWithMemoryTransport):
More information about the bazaar-commits
mailing list