[PATCH] even more python patches

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Thu Nov 1 00:17:29 UTC 2018


>>> [PATCH 08/17] tests/py/rodc_rwdc: avoid py2/py3 .next compat issues
>>>
>>> class RodcRwdcTests(password_lockout_base.BasePasswordTestCase):
>>> -    counter = itertools.count(1).next
>>> +    next_user_number = [1]
>>>
>>
>> I didn't get why a list was used for next_user_number, was there some
>> reason why just a normal variable wouldn't work? Anyway I think if the
>> orig style of code was to be ported below would be more in line and
>> *should* (hasn't been tested) work
> 
> OK, yes, that was a sad hack. The reason a normal variable won't work is
> each test gets its own instance of the class, and assigning to it will
> only overlay the class copy with an instance copy, meaning the counter
> doesn't count.
> 
> I'm going to leave that out right now, because it seems more important
> that I have lunch than sort it out.

What I should have said (it came to me at lunch) is that your approach:


> @@ -115,7 +115,6 @@ def get_server_ref_from_samdb(samdb):
> 
> 
>  class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase):
> -    counter = itertools.count(1).next
> 
>      def _check_account_initial(self, dn):
>          self.force_replication()
> @@ -686,7 +685,7 @@ class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase):
> 
> 
>  class RodcRwdcTests(password_lockout_base.BasePasswordTestCase):
> -    counter = itertools.count(1).next
> +    counter = itertools.count(1,1)
> 
>      def force_replication(self, base=None):
>          if base is None:
> @@ -982,7 +981,7 @@ class RodcRwdcTests(password_lockout_base.BasePasswordTestCase):
>          self._test_add_modify_delete()
> 
>      def _new_user(self):
> -        username = "u%sX%s" % (self.tag[:12], self.counter())
> +        username = "u%sX%s" % (self.tag[:12], next(self.counter()))
>          password = 'password#1'
>          dn = 'CN=%s,CN=Users,%s' % (username, self.base_dn)
>          o = {
> 

should work and is probably best. Could you please try it?

cheers,
Douglas



More information about the samba-technical mailing list