I have models like this.

import unittest
from google.appengine.ext import testbed, ndb


class Foo(ndb.Model):
    number = ndb.IntegerProperty(default=0)
    
class Bar(ndb.Model):
    foo = ndb.StructuredProperty(Foo, default=Foo())


class TestFoo(unittest.TestCase):

    
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()


    def tearDown(self):
        self.testbed.deactivate()


    def test1(self):
        Bar().foo.number = 1
        self.assertEqual(0, Bar().foo.number)

    def test2(self):
        Bar(foo = Foo()).foo.number = 1
        self.assertEqual(0, Bar(foo = Foo()).foo.number)


Finding files... done.
Importing test modules ... done.

======================================================================
FAIL: test1 (equipments.TestFoo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\d7\server\equipments.py", line 40, in test1
    self.assertEqual(0, Bar().foo.number)
AssertionError: 0 != 1

----------------------------------------------------------------------
Ran 50 tests in 0.504s

FAILED (failures=1)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to