Python urllib 模块,splitpasswd() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用urllib.splitpasswd()

项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_splitpasswd(self):
        # Some of the password examples are not sensible, but it is added to
        # confirming to RFC2617 and addressing issue4675.
        splitpasswd = urllib.splitpasswd
        self.assertEqual(splitpasswd('user:ab'), ('user', 'ab'))
        self.assertEqual(splitpasswd('user:a\nb'), ('user', 'a\nb'))
        self.assertEqual(splitpasswd('user:a\tb'), ('user', 'a\tb'))
        self.assertEqual(splitpasswd('user:a\rb'), ('user', 'a\rb'))
        self.assertEqual(splitpasswd('user:a\fb'), ('user', 'a\fb'))
        self.assertEqual(splitpasswd('user:a\vb'), ('user', 'a\vb'))
        self.assertEqual(splitpasswd('user:a:b'), ('user', 'a:b'))
        self.assertEqual(splitpasswd('user:a b'), ('user', 'a b'))
        self.assertEqual(splitpasswd('user 2:ab'), ('user 2', 'ab'))
        self.assertEqual(splitpasswd('user+1:a+b'), ('user+1', 'a+b'))
        self.assertEqual(splitpasswd('user:'), ('user', ''))
        self.assertEqual(splitpasswd('user'), ('user', None))
        self.assertEqual(splitpasswd(':ab'), ('', 'ab'))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_splitpasswd(self):
        # Some of the password examples are not sensible, but it is added to
        # confirming to RFC2617 and addressing issue4675.
        splitpasswd = urllib.splitpasswd
        self.assertEqual(splitpasswd('user:ab'), ('user', 'ab'))
        self.assertEqual(splitpasswd('user:a\nb'), ('user', 'a\nb'))
        self.assertEqual(splitpasswd('user:a\tb'), ('user', 'a\tb'))
        self.assertEqual(splitpasswd('user:a\rb'), ('user', 'a\rb'))
        self.assertEqual(splitpasswd('user:a\fb'), ('user', 'a\fb'))
        self.assertEqual(splitpasswd('user:a\vb'), ('user', 'a\vb'))
        self.assertEqual(splitpasswd('user:a:b'), ('user', 'a:b'))
        self.assertEqual(splitpasswd('user:a b'), ('user', 'a b'))
        self.assertEqual(splitpasswd('user 2:ab'), ('user 2', 'ab'))
        self.assertEqual(splitpasswd('user+1:a+b'), ('user+1', 'a+b'))
        self.assertEqual(splitpasswd('user:'), ('user', ''))
        self.assertEqual(splitpasswd('user'), ('user', None))
        self.assertEqual(splitpasswd(':ab'), ('', 'ab'))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_splitpasswd(self):
        """Some of the password examples are not sensible, but it is added to
        confirming to RFC2617 and addressing issue4675.
        """
        self.assertEqual(('user', 'ab'),urllib.splitpasswd('user:ab'))
        self.assertEqual(('user', 'a\nb'),urllib.splitpasswd('user:a\nb'))
        self.assertEqual(('user', 'a\tb'),urllib.splitpasswd('user:a\tb'))
        self.assertEqual(('user', 'a\rb'),urllib.splitpasswd('user:a\rb'))
        self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb'))
        self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb'))
        self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b'))
        self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b'))
        self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab'))
        self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b'))
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_splitpasswd(self):
        """Some of the password examples are not sensible, but it is added to
        confirming to RFC2617 and addressing issue4675.
        """
        self.assertEqual(('user', 'ab'),urllib.splitpasswd('user:ab'))
        self.assertEqual(('user', 'a\nb'),urllib.splitpasswd('user:a\nb'))
        self.assertEqual(('user', 'a\tb'),urllib.splitpasswd('user:a\tb'))
        self.assertEqual(('user', 'a\rb'),urllib.splitpasswd('user:a\rb'))
        self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb'))
        self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb'))
        self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b'))
        self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b'))
        self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab'))
        self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b'))