[MERGE] Add get_username() call to the UIFactory.
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Apr 2 12:00:14 BST 2009
>>>>> "Jelmer" == Jelmer Vernooij <jelmer at samba.org> writes:
Jelmer> Vincent Ladeuil wrote:
>>>>>>> "Jelmer" == Jelmer Vernooij <jelmer at samba.org> writes:>
Jelmer> TestUIFactory provides a custom implementation of
Jelmer> get_non_echoed_password(); making it provide a mock
Jelmer> implementation of get_username() that doesn't raise
Jelmer> NotATerminal seems kind of pointless as we would only
Jelmer> be testing the mock implementation, not the actual
Jelmer> one.
>>
>> That's a different issue.
>>
>> If you mean NotATerminal is tested nowhere, you've found yet
>> another hole in our test suite, feel free to provide more tests
>> but I don't require them at that point (a FIXME: will do :)
So I sent a patch regarding NotATerminal, you may want to merge
from it once it lands.
Jelmer> Attached is an updated version that no longer uses
Jelmer> NotATerminal and tests utf8, as we discussed on IRC.
Could you refactor a bit instead of blindly copy/pasting there ?
<snip/>
Jelmer> +
Jelmer> + def test_text_ui_getusername_utf8(self):
Jelmer> + ui = TestUIFactory(stdin=u'someuser\u1234'.encode('utf8'),
Jelmer> + stdout=StringIOWrapper())
Jelmer> + ui.stdin.encoding = "utf8"
Jelmer> + ui.stdout.encoding = ui.stdin.encoding
Jelmer> + pb = ui.nested_progress_bar()
Jelmer> + try:
Jelmer> + # there is no output from the base factory
Jelmer> + password = ui.get_username(u'Hello\u1234 %(host)s',
Jelmer> + host=u'some\u1234')
Jelmer> + self.assertEquals(u"someuser\u1234", password.decode('utf8'))
If you don't refactor, at least rename the variables:
s/password/username/...
I also think encoding username/password to utf-8 may need to be
discussed as AFAICS we aren't very clear about what is really
needed here and what we really do in the code base.
I won't block on that as using utf8 is compatible with ascii and
until we encounter the problem (as in someone file a bug) we may
as well continue as we do now: leave upper levels handle the
encoding.
Vincent
More information about the bazaar
mailing list