[MERGE] handle wacky plugin behavior in test suite
Aaron Bentley
aaron.bentley at utoronto.ca
Thu Feb 15 17:55:15 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jelmer Vernooij wrote:
> The GTK plugin doesn't actually make any changes to the encoding itself
> (or at least, I can't find the code that does). It very much looks like
> it's pygtk that does :-(
>
> In other words, there would be no way to fix the encoding in bzr-gtk
> easily.
Well, for the test suite, there's brute force:
def test_suite():
from unittest import TestSuite
import tests
- - result = TestSuite()
- - result.addTest(tests.test_suite())
+ import sys
+ default_encoding = sys.getdefaultencoding()
+ try:
+ result = TestSuite()
+ result.addTest(tests.test_suite())
+ finally:
+ reload(sys)
+ sys.setdefaultencoding(default_encoding)
A somewhat better solution would be to figure out which module is
changing the encoding, load it in import_pygtk, and then fix the encoding.
On the bright side, the encoding seems to only be changed when the test
suite or bzr-gtk commands are run. Otherwise, my test suite fix would
not work.
> I guess that would be the best attempt at fixing this, though I think
> the fact that importing gtk or cairo stuff causes the encoding to change
> is scary.
For me, it's not cairo, because I don't have it installed.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFF1J6D0F+nu1YWqI0RAjo5AJ9qCLFis7uB/psIwS58PLdZ7f3zLQCeOtpW
CkgnguoCkY9hibvmgSKr/Uc=
=O7I5
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list