diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2013-02-15 09:50:46 +0100 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2013-02-15 09:50:46 +0100 |
commit | dbf8429a76013f48fbfa365c1b8f53b4e68acf1d (patch) | |
tree | cc976a71c2f339c698bd0e768de9242e36ec564a /test | |
parent | 106fd424de7954b57512cef4c4c2c2c21622ecb0 (diff) | |
download | logilab-common-dbf8429a76013f48fbfa365c1b8f53b4e68acf1d.tar.gz |
fix umessages test w/ python 3 and LC_ALL=C (closes #119967)
Diffstat (limited to 'test')
-rw-r--r-- | test/unittest_umessage.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/test/unittest_umessage.py b/test/unittest_umessage.py index 6bf56c6..edd7633 100644 --- a/test/unittest_umessage.py +++ b/test/unittest_umessage.py @@ -16,6 +16,7 @@ # # You should have received a copy of the GNU Lesser General Public License along # with logilab-common. If not, see <http://www.gnu.org/licenses/>. +import sys import email from os.path import join, dirname, abspath @@ -27,9 +28,14 @@ DATA = join(dirname(abspath(__file__)), 'data') class UMessageTC(TestCase): def setUp(self): - msg1 = email.message_from_file(open(join(DATA, 'test1.msg'))) + if sys.version_info >= (3, 2): + import io + msg1 = email.message_from_file(io.open(join(DATA, 'test1.msg'), encoding='utf8')) + msg2 = email.message_from_file(io.open(join(DATA, 'test2.msg'), encoding='utf8')) + else: + msg1 = email.message_from_file(open(join(DATA, 'test1.msg'))) + msg2 = email.message_from_file(open(join(DATA, 'test2.msg'))) self.umessage1 = UMessage(msg1) - msg2 = email.message_from_file(open(join(DATA, 'test2.msg'))) self.umessage2 = UMessage(msg2) def test_get_subject(self): |