[RFC] more encodings tests [was: bzr handles unicode]

John Arbash Meinel john at arbash-meinel.com
Sat Jan 7 15:54:54 GMT 2006


Alexander Belchenko wrote:
> John Arbash Meinel пишет:
> 
>> Alexander Belchenko wrote:
>>
>>> +    def test_stdout_ascii(self):
>>> +        sys.stdout = StringIO()
>>> +        bzrlib.user_encoding = 'ascii'
>>> +        working_tree = self.make_uncommitted_tree()
>>> +        stdout, stderr = self.run_bzr_captured(["--no-plugins",
>>> "status"])
>>
>>
>>
>> Looking at this closer, is there a reason you are using '--no-plugins'?
>> I don't believe it has any effect at this point. run_bzr_captured() just
>> calls into the library, it doesn't spawn bzr. So unless you run 'bzr
>> --no-plugins selftest' the plugins are already loaded.
> 
> 
> I'm was not sure about how run_bzr works so I think that extra
> '--no-plugins' will not bad. And yes, I run selftest always with
> '--no-plugins' flag because bzrtools selftests fails on windows.
> If you think that this flag is needless in tests I will not use it in
> future.

Actually, you need to use:
BZR_PLUGIN_PATH='' ./bzr selftest

I was just testing this, and when you run './bzr --no-plugins selftest',
it doesn't load the plugins at the beginning, but it does load them at
the time you call run_bzr.
However, since we don't want to put --no-plugins everywhere, we probably
need to change how run_bzr works.

> 
>> I also find:
>>
>> stdout, stderr = self.run_bzr('--no-plugins', 'status')
>> easier to write, because you don't have to also provide [].
> 
> 
> Yes. I think because this form is syntax sugar for new python2.4
> generators syntax (PEP289):
> 
> self.run_bzr('--no-plugins', 'status')
> 
> is equal to:
> 
> self.run_bzr(('--no-plugins', 'status'))
> 
> Lately I discover this fact: but this syntax incompatible with python2.3
> that I use in my embedded system project. So I try to be more explicit
> and use backward compatible syntax if I can.
> 
> -- 
> Alexander
> 


Actually, no it isn't. Actually, what is going on is that we defined:
def run_bzr(*args, **kwargs):
	...
That lets us take an arbitrary number of arguments, and *args ends up
being a tuple, and **kwargs ends up being a dictionary.
This has been the standard method for passing arbitrary parameters in
python for quite some time. I think for the whole 2.x series.

Though I know you can do:

a_function(foo for foo in something)

Which will treat the above as a generator, and pass it into a_function.
I don't know whether it passes it as the first argument, or as all
arguments, though. (I'm guessing the first argument)
But that isn't what we are using.

(run_bzr_captured requires that you pass a list as the first argument,
run_bzr() takes an arbitrary number of arguments)

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060107/bfc0dbed/attachment.pgp 


More information about the bazaar mailing list