Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

using setUpClass (2.7) instead of setUp

  • Loading branch information...
commit 6f1b51c50f18c9089be571349049c58f2e16ef70 1 parent cdef76c
Eugene Van den Bulke authored August 18, 2011

Showing 1 changed file with 52 additions and 50 deletions. Show diff stats Hide diff stats

  1. 102  test_cherrys.py
102  test_cherrys.py
@@ -39,56 +39,58 @@ def test_nothing(self):
39 39
 # all good to go we can test
40 40
 else:
41 41
 
42  
-  import cherrys
43  
-  cherrypy.lib.sessions.RedisSession = cherrys.RedisSession
44  
-
45  
-  class RedisSessionTest(webtest.WebCase):
46  
-
47  
-      interactive = False
48  
-
49  
-      def setUp(self):
50  
-          # configuring CP instead of webCase (getPage - openUrl on port 8000)
51  
-          cherrypy.config.update({
52  
-              'server.socket_port' : 8000,
53  
-              'log.screen' : False,
54  
-              'tools.sessions.on' : True,
55  
-              'tools.sessions.storage_type' : 'redis'
56  
-          })
57  
-          cherrypy.tree.mount(App())
58  
-          cherrypy.engine.start()
59  
-
60  
-      def test_server_working(self):
61  
-          self.getPage('/')
62  
-          self.assertStatus(200)
63  
-
64  
-      def test_deleting_non_existing_key_fails(self):
65  
-          self.getPage('/delete')
66  
-          self.assertStatus(500)
67  
-
68  
-      def test_deleting_stored_data(self):
69  
-          self.getPage('/store')
70  
-          self.assertStatus(200)
71  
-          # first getPage call sets a cookie
72  
-          # second getPage call needs to be aware of the cookie
73  
-          self.getPage('/delete', self.cookies)
74  
-          self.assertStatus(200)
75  
-
76  
-      def test_storing_data(self):
77  
-          self.getPage('/store')
78  
-          self.assertStatus(200)
79  
-          self.assertBody('redis')
80  
-
81  
-      def test_retrieving_stored_data(self):
82  
-          self.getPage('/retrieve')
83  
-          self.assertStatus(500)
84  
-          self.getPage('/store', self.cookies)
85  
-          self.assertStatus(200)
86  
-          self.assertBody('redis')
87  
-          self.getPage('/retrieve', self.cookies)
88  
-          self.assertStatus(200)
89  
-
90  
-      def tearDown(self):
91  
-          cherrypy.engine.exit()
  42
+    import cherrys
  43
+    cherrypy.lib.sessions.RedisSession = cherrys.RedisSession
  44
+
  45
+    class RedisSessionTest(webtest.WebCase):
  46
+
  47
+        interactive = False
  48
+
  49
+        @classmethod
  50
+        def setUpClass(cls):
  51
+            # configuring CP instead of webCase (getPage - openUrl on port 8000)
  52
+            cherrypy.config.update({
  53
+                'server.socket_port' : 8000,
  54
+                'log.screen' : False,
  55
+                'tools.sessions.on' : True,
  56
+                'tools.sessions.storage_type' : 'redis'
  57
+            })
  58
+            cherrypy.tree.mount(App())
  59
+            cherrypy.engine.start()
  60
+
  61
+        def test_server_working(self):
  62
+            self.getPage('/')
  63
+            self.assertStatus(200)
  64
+
  65
+        def test_deleting_non_existing_key_fails(self):
  66
+            self.getPage('/delete')
  67
+            self.assertStatus(500)
  68
+
  69
+        def test_deleting_stored_data(self):
  70
+            self.getPage('/store')
  71
+            self.assertStatus(200)
  72
+            # first getPage call sets a cookie
  73
+            # second getPage call needs to be aware of the cookie
  74
+            self.getPage('/delete', self.cookies)
  75
+            self.assertStatus(200)
  76
+
  77
+        def test_storing_data(self):
  78
+            self.getPage('/store')
  79
+            self.assertStatus(200)
  80
+            self.assertBody('redis')
  81
+
  82
+        def test_retrieving_stored_data(self):
  83
+            self.getPage('/retrieve')
  84
+            self.assertStatus(500)
  85
+            self.getPage('/store', self.cookies)
  86
+            self.assertStatus(200)
  87
+            self.assertBody('redis')
  88
+            self.getPage('/retrieve', self.cookies)
  89
+            self.assertStatus(200)
  90
+
  91
+        @classmethod
  92
+        def tearDownClass(cls):
  93
+            cherrypy.engine.exit()
92 94
 
93 95
 class App(object):
94 96
     """ A basic application to test sessions """

0 notes on commit 6f1b51c

Please sign in to comment.
Something went wrong with that request. Please try again.