Skip to content

Instantly share code, notes, and snippets.

@mryoshio
Last active December 17, 2015 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mryoshio/5559311 to your computer and use it in GitHub Desktop.
Save mryoshio/5559311 to your computer and use it in GitHub Desktop.
unittest example for Python
import unittest
from google.appengine.api import users
from google.appengine.ext import db
from google.appengine.ext import testbed
from model import Group
class GroupTestCase(unittest.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_user_stub()
def tearDown(self):
self.testbed.deactivate()
def test_insert_entity(self):
Group(
name = 'Mike Davis',
owner = users.User(email='test@example.com', _user_id='1234567890')
).put()
self.assertEqual(1, len(Group.all().fetch(2)))
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment