Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:02:21+00:00 2026-06-01T01:02:21+00:00

I have a function that uses the Google Blobstore API, and here’s a degenerate

  • 0

I have a function that uses the Google Blobstore API, and here’s a degenerate case:

#!/usr/bin/python
from google.appengine.ext import testbed

def foo():
    from google.appengine.api import files
    blob_filename = files.blobstore.create(mime_type='text/plain')
    with files.open(blob_filename, 'a') as googfile:
        googfile.write("Test data")

    files.finalize(blob_filename)

tb = testbed.Testbed()
tb.activate()
tb.init_blobstore_stub()

foo() # in reality, I'm a function called from a 'faux client'
      # in a unittest testcase.

The error this generates is:

Traceback (most recent call last):
  File "e.py", line 18, in 
    foo() # in reality, I'm a function called from a 'faux client'
  File "e.py", line 8, in foo
    blob_filename = files.blobstore.create(mime_type='text/plain')
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/files/blobstore.py", line 68, in create
    return files._create(_BLOBSTORE_FILESYSTEM, params=params)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/files/file.py", line 491, in _create
    _make_call('Create', request, response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/files/file.py", line 230, in _make_call
    rpc = _create_rpc(deadline=deadline)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/files/file.py", line 213, in _create_rpc
    return apiproxy_stub_map.UserRPC('file', deadline)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 393, in __init__
    self.__rpc = CreateRPC(service, stubmap)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 67, in CreateRPC
    assert stub, 'No api proxy found for service "%s"' % service
AssertionError: No api proxy found for service "file"

I don’t want to have to modify foo in order to be able to test it. Is there a way to make foo work as expected (i.e. create the given file) in Google App Engine’s unit tests?

I would expect to be able to do this with Google’s API Proxy, but I don’t understand it well enough to figure it out on my own.

I’d be grateful for your thoughts and suggestions.

Thanks for reading.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:02:23+00:00Added an answer on June 1, 2026 at 1:02 am

    It seems like testbed.init_blobstore_stub() is outdated, because dev_appserver inits blobstore stubs differently. Here is my implementation of init_blobstore_stub that allows you to write to and read from blobstore in your tests.

    from google.appengine.ext import testbed
    from google.appengine.api.blobstore import blobstore_stub, file_blob_storage
    from google.appengine.api.files import file_service_stub
    
    class TestbedWithFiles(testbed.Testbed):
    
        def init_blobstore_stub(self):
            blob_storage = file_blob_storage.FileBlobStorage('/tmp/testbed.blobstore',
                                                    testbed.DEFAULT_APP_ID)
            blob_stub = blobstore_stub.BlobstoreServiceStub(blob_storage)
            file_stub = file_service_stub.FileServiceStub(blob_storage)
            self._register_stub('blobstore', blob_stub)
            self._register_stub('file', file_stub)
    
    # Your code...
    def foo():
        from google.appengine.api import files
        blob_filename = files.blobstore.create(mime_type='text/plain')
        with files.open(blob_filename, 'a') as googfile:
            googfile.write("Test data")
    
        files.finalize(blob_filename)
    
    tb = TestbedWithFiles()
    tb.activate()
    tb.init_blobstore_stub()
    
    foo()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that uses Win API function RegSaveKeyEx to save registry entries to
We have system here that uses Java JNI to call a function in a
I have a Google Map API v3 map object on a page that uses
I have a google spreadsheet that uses this function: =SUM(E:E) - SUM(C:C) It adds
I am a Google Maps API (JavaScript) developer. I have noticed that Google uses
I'm working on an application that uses the Google Maps API. I have no
I have a webpage that heavily uses Javascript (AJAX requests, Google Maps API, HTML
Here's my conundrum: I have a page that uses Google Maps V3 and jQuery.
I have a web app that uses Google Maps API v3. I have it
I'm creating a function uses Google's API to import contacts from a person's gmail

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.