Robert Brewer avatar Robert Brewer committed 558eb46

Fix for #506 (unrepr should support negative numbers).

Comments (0)

Files changed (2)

cherrypy/lib/__init__.py

     
     def build_NoneType(self, o):
         return None
+    
+    def build_UnarySub(self, o):
+        return -self.build_Const(o.getChildren()[0])
+    
+    def build_UnaryAdd(self, o):
+        return self.build_Const(o.getChildren()[0])
 
 
 def unrepr(s):

cherrypy/test/test_config.py

         def index(self, key):
             return cherrypy.request.config.get(key, "None")
         index = cherrypy.expose(index, alias=('global_', 'xyz'))
+        
+        def repr(self, key):
+            return repr(cherrypy.request.config.get(key, None))
+        repr.exposed = True
     
     class Foo:
         
             return str(cherrypy.request.config.get(key, "None"))
         index.exposed = True
     
+    ioconf = StringIO.StringIO("""
+[/]
+neg: -1234
+""")
+    
     root = Root()
     root.foo = Foo()
-    cherrypy.tree.mount(root)
+    cherrypy.tree.mount(root, config=ioconf)
     cherrypy.tree.mount(Another(), "/another")
     cherrypy.config.update({'environment': 'test_suite'})
     
             ('/',        'nex', 'None'),
             ('/',        'foo', 'this'),
             ('/',        'bar', 'that'),
+            ('/repr',    'neg', '-1234'),
             ('/xyz',     'foo', 'this'),
             ('/foo/',    'foo', 'this2'),
             ('/foo/',    'bar', 'that'),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.