On 11 September 2010 00:44, Vincent Ladeuil <email address hidden> wrote:
> -class TestGetBackupName(TestCase):
> - def test_get_backup_name(self):
> +class TestBackupName(tests.TestCase):
> +
> + def test_deprecations(self):
> + class MockTransform(object):
> +
> + def has_named_child(self, by_parent, parent_id, name):
> + return name in by_parent.get(parent_id, [])
> +
> + class MockEntry(object):
> +
> + def __init__(self):
> + object.__init__(self)
> + self.name = "name"
> +
Generally I'd only put the mock object inside the method if I was sure
it would only be used from there, which is probably true now this is
deprecated.
I like the style insisted upon by Launchpad of using only 4-character
indents for continuation lines... I think we say it's not a big deal
and it's not.
> +@deprecated_function(deprecated_in((2, 3, 0)))
> def _get_backup_name(name, by_parent, parent_trans_id, tt):
> """Produce a backup-style name that appears to be available"""
> def name_gen():
> @@ -2697,9 +2722,8 @@
> tt.delete_contents(trans_id)
> elif kind[1] is not None:
> parent_trans_id = tt.trans_id_file_id(parent[0])
> - by_parent = tt.by_parent()
> - backup_name = _get_backup_name(name[0], by_parent,
> - parent_trans_id, tt)
> + backup_name = tt._available_backup_name(name[0],
> + parent_trans_id)
On 11 September 2010 00:44, Vincent Ladeuil <email address hidden> wrote: me(TestCase) : backup_ name(self) : tests.TestCase) : ns(self) : object) : child(self, by_parent, parent_id, name): get(parent_ id, []) __init_ _(self)
> -class TestGetBackupNa
> - def test_get_
> +class TestBackupName(
> +
> + def test_deprecatio
> + class MockTransform(
> +
> + def has_named_
> + return name in by_parent.
> +
> + class MockEntry(object):
> +
> + def __init__(self):
> + object.
> + self.name = "name"
> +
Generally I'd only put the mock object inside the method if I was sure
it would only be used from there, which is probably true now this is
deprecated.
> + name2 = self.applyDepre cated( versioning. deprecated_ in((2, 3, 0)), _get_backup_ name, 'name', {'a':['name.~1~']}, 'a', tt) l('name. ~2~', name2)
> + symbol_
> + transform.
> + self.assertEqua
I like the style insisted upon by Launchpad of using only 4-character
indents for continuation lines... I think we say it's not a big deal
and it's not.
> +@deprecated_ function( deprecated_ in((2, 3, 0))) name(name, by_parent, parent_trans_id, tt): contents( trans_id) id_file_ id(parent[ 0]) name(name[ 0], by_parent, backup_ name(name[ 0],
> def _get_backup_
> """Produce a backup-style name that appears to be available"""
> def name_gen():
> @@ -2697,9 +2722,8 @@
> tt.delete_
> elif kind[1] is not None:
> parent_trans_id = tt.trans_
> - by_parent = tt.by_parent()
> - backup_name = _get_backup_
> - parent_trans_id, tt)
> + backup_name = tt._available_
> + parent_trans_id)
This to me is a clear case where the other indent rule is cleaner. /dev.launchpad. net/PythonStyle Guide#Multiline +function+ calls>
<https:/
The substance seems fine.
--
Martin