0
私のPython Google App Engineアプリケーションにはwritten some unittestsがあります。以下は、問題のあるコードの抜粋です。Python IOモジュールの未知のエンコーディングunittesting GAE
class TestCase(unittest.TestCase):
def setUp(self):
from google.appengine.ext import testbed
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_urlfetch_stub()
self.testbed.init_blobstore_stub()
ndb.get_context().clear_cache()
def tearDown(self):
self.testbed.deactivate()
def testing(self):
from google.cloud import storage
client = storage.Client()
ファイルを開いている間、私はio
ライブラリを使用して(私のgcloudアプリケーションの資格情報)エンコーディングLookupErrorがを取得しています。ここで
は、関連するスタックトレースと違反(pytestから)io
コードです:
self = <test_1.TestCase testMethod=testing>
def testing(self):
from google.cloud import storage
> client = storage.Client()
/Users/alex/projects/don/don_server/mobile/tests/test_1.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/alex/projects/don/don_server/lib/google/cloud/storage/client.py:59: in __init__
_http=_http)
/Users/alex/projects/don/don_server/lib/google/cloud/client.py:223: in __init__
_ClientProjectMixin.__init__(self, project=project)
/Users/alex/projects/don/don_server/lib/google/cloud/client.py:177: in __init__
project = self._determine_default(project)
/Users/alex/projects/don/don_server/lib/google/cloud/client.py:190: in _determine_default
return _determine_default_project(project)
/Users/alex/projects/don/don_server/lib/google/cloud/_helpers.py:181: in _determine_default_project
_, project = google.auth.default()
/Users/alex/projects/don/don_server/lib/google/auth/_default.py:277: in default
credentials, project_id = checker()
/Users/alex/projects/don/don_server/lib/google/auth/_default.py:117: in _get_gcloud_sdk_credentials
credentials_filename)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
filename = '/Users/name/.config/gcloud/application_default_credentials.json'
def _load_credentials_from_file(filename):
"""Loads credentials from a file.
The credentials file must be a service account key or stored authorized
user credentials.
Args:
filename (str): The full path to the credentials file.
Returns:
Tuple[google.auth.credentials.Credentials, Optional[str]]: Loaded
credentials and the project ID. Authorized user credentials do not
have the project ID information.
Raises:
google.auth.exceptions.DefaultCredentialsError: if the file is in the
wrong format.
"""
> with io.open(filename, 'r') as file_obj:
E LookupError: unknown encoding:
私はGAEローカルの開発サーバー上でこのコードを実行したときに私はこのエラーを得ることはありません。さらに、シェルを使用して資格情報ファイルを開くと(ioモジュールのファイル属性をチェックしても同じです)、エラーは発生しません。