r46839 - ensure that the rest of strports is actually ported

hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: hawkowl
Date: Wed Feb 24 04:44:04 2016
New Revision: 46839

Modified:
   branches/strcred-dist3-8216/twisted/cred/checkers.py
   branches/strcred-dist3-8216/twisted/cred/strcred.py
   branches/strcred-dist3-8216/twisted/cred/test/test_strcred.py
   branches/strcred-dist3-8216/twisted/python/dist3.py

Log:
ensure that the rest of strports is actually ported

Modified: branches/strcred-dist3-8216/twisted/cred/checkers.py
==============================================================================
--- branches/strcred-dist3-8216/twisted/cred/checkers.py	(original)
+++ branches/strcred-dist3-8216/twisted/cred/checkers.py	Wed Feb 24 04:44:04 2016
@@ -95,7 +95,7 @@
             return defer.maybeDeferred(
                 credentials.checkPassword,
                 self.users[credentials.username]).addCallback(
-                self._cbPasswordMatch, bytes(credentials.username))
+                self._cbPasswordMatch, credentials.username)
         else:
             return defer.fail(error.UnauthorizedLogin())
 

Modified: branches/strcred-dist3-8216/twisted/cred/strcred.py
==============================================================================
--- branches/strcred-dist3-8216/twisted/cred/strcred.py	(original)
+++ branches/strcred-dist3-8216/twisted/cred/strcred.py	Wed Feb 24 04:44:04 2016
@@ -1,4 +1,4 @@
-# -*- test-case-name: twisted.test.test_strcred -*-
+# -*- test-case-name: twisted.cred.test.test_strcred -*-
 #
 # Copyright (c) Twisted Matrix Laboratories.
 # See LICENSE for details.
@@ -14,6 +14,8 @@
  - unix
 """
 
+from __future__ import absolute_import, division
+
 import sys
 
 from zope.interface import Interface, Attribute

Modified: branches/strcred-dist3-8216/twisted/cred/test/test_strcred.py
==============================================================================
--- branches/strcred-dist3-8216/twisted/cred/test/test_strcred.py	(original)
+++ branches/strcred-dist3-8216/twisted/cred/test/test_strcred.py	Wed Feb 24 04:44:04 2016
@@ -8,7 +8,6 @@
 from __future__ import absolute_import, division
 
 import os
-from io import BytesIO
 
 from twisted import plugin
 from twisted.trial import unittest
@@ -19,6 +18,11 @@
 from twisted.python.fakepwd import UserDatabase
 from twisted.python.reflect import requireModule
 
+if compat._PY3:
+    from io import StringIO
+else:
+    from io import BytesIO as StringIO
+
 try:
     import crypt
 except ImportError:
@@ -267,12 +271,12 @@
     """
 
     def setUp(self):
-        self.admin = credentials.UsernamePassword('admin', 'asdf')
-        self.alice = credentials.UsernamePassword('alice', 'foo')
-        self.badPass = credentials.UsernamePassword('alice', 'foobar')
-        self.badUser = credentials.UsernamePassword('x', 'yz')
+        self.admin = credentials.UsernamePassword(b'admin', b'asdf')
+        self.alice = credentials.UsernamePassword(b'alice', b'foo')
+        self.badPass = credentials.UsernamePassword(b'alice', b'foobar')
+        self.badUser = credentials.UsernamePassword(b'x', b'yz')
         self.filename = self.mktemp()
-        FilePath(self.filename).setContent('admin:asdf\nalice:foo\n')
+        FilePath(self.filename).setContent(b'admin:asdf\nalice:foo\n')
         self.checker = strcred.makeChecker('file:' + self.filename)
 
 
@@ -334,7 +338,7 @@
         should produce a warning.
         """
         oldOutput = cred_file.theFileCheckerFactory.errorOutput
-        newOutput = BytesIO()
+        newOutput = StringIO()
         cred_file.theFileCheckerFactory.errorOutput = newOutput
         strcred.makeChecker('file:' + self._fakeFilename())
         cred_file.theFileCheckerFactory.errorOutput = oldOutput
@@ -458,7 +462,7 @@
         Test that the --help-auth argument correctly displays all
         available authentication plugins, then exits.
         """
-        newStdout = BytesIO()
+        newStdout = StringIO()
         options = DummyOptions()
         options.authOutput = newStdout
         self.assertRaises(SystemExit, options.parseOptions, ['--help-auth'])
@@ -471,7 +475,7 @@
         Test that the --help-auth-for argument will correctly display
         the help file for a particular authentication plugin.
         """
-        newStdout = BytesIO()
+        newStdout = StringIO()
         options = DummyOptions()
         options.authOutput = newStdout
         self.assertRaises(
@@ -533,7 +537,8 @@
 
     def setUp(self):
         self.filename = self.mktemp()
-        file(self.filename, 'w').write('admin:asdf\nalice:foo\n')
+        with open(self.filename, 'wb') as f:
+            f.write(b'admin:asdf\nalice:foo\n')
         self.goodChecker = checkers.FilePasswordDB(self.filename)
         self.badChecker = checkers.FilePasswordDB(
             self.filename, hash=self._hash)
@@ -655,7 +660,7 @@
                 break
         self.assertNotIdentical(invalidFactory, None)
         # Capture output and make sure the warning is there
-        newStdout = BytesIO()
+        newStdout = StringIO()
         options.authOutput = newStdout
         self.assertRaises(SystemExit, options.parseOptions,
                           ['--help-auth-type', 'anonymous'])
@@ -667,11 +672,3 @@
     "SSHCheckerTests", "UnixCheckerTests", "AnonymousCheckerTests",
     "MemoryCheckerTests", "StrcredFunctionsTests", "PublicAPITests"
 ]
-
-
-if compat._PY3:
-    __all3__ = ["SSHCheckerTests", "PublicAPITests", "StrcredFunctionsTests"]
-    for name in __all__[:]:
-        if name not in __all3__:
-            globals()[name].skip = "Not yet ported to Python 3."
-    del name, __all3__

Modified: branches/strcred-dist3-8216/twisted/python/dist3.py
==============================================================================
--- branches/strcred-dist3-8216/twisted/python/dist3.py	(original)
+++ branches/strcred-dist3-8216/twisted/python/dist3.py	Wed Feb 24 04:44:04 2016
@@ -59,6 +59,7 @@
     "twisted.cred.credentials",
     "twisted.cred.error",
     "twisted.cred.portal",
+    "twisted.cred.strcred"
     "twisted.cred.test",
     "twisted.internet",
     "twisted.internet._baseprocess",
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.