1. Franck Bret
  2. CherryPy


Jason R. Coombs  committed 1265d12

Added test to ensure that login_screen returns bytes - regression test for #1132.

  • Participants
  • Parent commits 200ab3b
  • Branches cherrypy-3.2.x

Comments (0)

Files changed (1)

File cherrypy/test/test_tools.py

View file
  • Ignore whitespace
 import gzip
 import sys
+import unittest
 from cherrypy._cpcompat import BytesIO, copyitems, itervalues
 from cherrypy._cpcompat import IncompleteRead, ntob, ntou, py3k, xrange
+from cherrypy._cpcompat import bytestr
 import time
 timeout = 0.2
 import types
             raise AssertionError("Tool.on did not error as it should have.")
+class SessionAuthTest(unittest.TestCase):
+    def test_login_screen_returns_bytes(self):
+        """
+        login_screen must return bytes even if unicode parameters are passed.
+        Issue 1132 revealed that login_screen would return unicode if the
+        username and password were unicode.
+        """
+        sa = cherrypy.lib.cptools.SessionAuth()
+        res = sa.login_screen(None, username=u'nobody', password=u'anypass')
+        self.assertIsInstance(res, bytestr)