Commits

Jean-Tiare Le Bigot committed de4b939

make db connection in example more consistent with test philosophy

Comments (0)

Files changed (1)

docs/pages/getting_started.rst

 
     class TestGetItem(unittest.TestCase):
         def setUp(self):
+            from ddbmock import connect_boto_patch
             from ddbmock.database.db import dynamodb
             from ddbmock.database.table import Table
             from ddbmock.database.key import PrimaryKey
             # Unconditionally add some data, for example.
             self.t1.put(ITEM, {})
 
+            # Create the database connection ie: patch boto
+            self.db = connect_boto_patch()
+
         def tearDown(self):
             from ddbmock.database.db import dynamodb
             from ddbmock import clean_boto_patch
             clean_boto_patch()
 
         def test_get_hr(self):
-            from ddbmock import connect_boto_patch
             from ddbmock.database.db import dynamodb
 
-            # Create the database connection ie: patch boto
-            db = connect_boto_patch()
-
             # Example test
             expected = {
                 u'ConsumedCapacityUnits': 0.5,
             }
 
             # Example chech
-            self.assertEquals(expected, db.layer1.get_item(TABLE_NAME, key))
+            self.assertEquals(expected, self.db.layer1.get_item(TABLE_NAME, key))
 
 
 If ddbmock is used as a standalone server, restarting it should do the job, unless