Author: tomaz
Date: Mon Dec 5 00:02:32 2011
New Revision: 1210285
URL: http://svn.apache.org/viewvc?rev=1210285&view=rev
Log:
Explicitly pass encoding to file.open when using Python 3. Otherwise tests might
fail in some circumstances when locate is not set.
Modified:
libcloud/trunk/test/file_fixtures.py
Modified: libcloud/trunk/test/file_fixtures.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/test/file_fixtures.py?rev=1210285&r1=1210284&r2=1210285&view=diff
==============================================================================
--- libcloud/trunk/test/file_fixtures.py (original)
+++ libcloud/trunk/test/file_fixtures.py Mon Dec 5 00:02:32 2011
@@ -18,6 +18,7 @@ from __future__ import with_statement
import os
+from libcloud.utils.py3 import PY3
from libcloud.utils.py3 import u
FIXTURES_ROOT = {
@@ -37,7 +38,12 @@ class FileFixtures(object):
def load(self, file):
path = os.path.join(self.root, file)
if os.path.exists(path):
- with open(path, 'r') as fh:
+ if PY3:
+ kwargs = {'encoding': 'utf-8'}
+ else:
+ kwargs = {}
+
+ with open(path, 'r', **kwargs) as fh:
content = fh.read()
return u(content)
else: