当前位置: 首页>>代码示例>>Python>>正文


Python getpass.unix_getpass方法代码示例

本文整理汇总了Python中getpass.unix_getpass方法的典型用法代码示例。如果您正苦于以下问题:Python getpass.unix_getpass方法的具体用法?Python getpass.unix_getpass怎么用?Python getpass.unix_getpass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在getpass的用法示例。


在下文中一共展示了getpass.unix_getpass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_uses_tty_directly

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import unix_getpass [as 别名]
def test_uses_tty_directly(self):
        with mock.patch('os.open') as open, \
                mock.patch('io.FileIO') as fileio, \
                mock.patch('io.TextIOWrapper') as textio:
            # By setting open's return value to None the implementation will
            # skip code we don't care about in this test.  We can mock this out
            # fully if an alternate implementation works differently.
            open.return_value = None
            getpass.unix_getpass()
            open.assert_called_once_with('/dev/tty',
                                         os.O_RDWR | os.O_NOCTTY)
            fileio.assert_called_once_with(open.return_value, 'w+')
            textio.assert_called_once_with(fileio.return_value) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_getpass.py

示例2: test_resets_termios

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import unix_getpass [as 别名]
def test_resets_termios(self):
        with mock.patch('os.open') as open, \
                mock.patch('io.FileIO'), \
                mock.patch('io.TextIOWrapper'), \
                mock.patch('termios.tcgetattr') as tcgetattr, \
                mock.patch('termios.tcsetattr') as tcsetattr:
            open.return_value = 3
            fake_attrs = [255, 255, 255, 255, 255]
            tcgetattr.return_value = list(fake_attrs)
            getpass.unix_getpass()
            tcsetattr.assert_called_with(3, mock.ANY, fake_attrs) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_getpass.py

示例3: test_falls_back_to_fallback_if_termios_raises

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import unix_getpass [as 别名]
def test_falls_back_to_fallback_if_termios_raises(self):
        with mock.patch('os.open') as open, \
                mock.patch('io.FileIO') as fileio, \
                mock.patch('io.TextIOWrapper') as textio, \
                mock.patch('termios.tcgetattr'), \
                mock.patch('termios.tcsetattr') as tcsetattr, \
                mock.patch('getpass.fallback_getpass') as fallback:
            open.return_value = 3
            fileio.return_value = BytesIO()
            tcsetattr.side_effect = termios.error
            getpass.unix_getpass()
            fallback.assert_called_once_with('Password: ',
                                             textio.return_value) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_getpass.py

示例4: test_flushes_stream_after_input

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import unix_getpass [as 别名]
def test_flushes_stream_after_input(self):
        # issue 7208
        with mock.patch('os.open') as open, \
                mock.patch('io.FileIO'), \
                mock.patch('io.TextIOWrapper'), \
                mock.patch('termios.tcgetattr'), \
                mock.patch('termios.tcsetattr'):
            open.return_value = 3
            mock_stream = mock.Mock(spec=StringIO)
            getpass.unix_getpass(stream=mock_stream)
            mock_stream.flush.assert_called_with() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_getpass.py

示例5: test_falls_back_to_stdin

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import unix_getpass [as 别名]
def test_falls_back_to_stdin(self):
        with mock.patch('os.open') as os_open, \
                mock.patch('sys.stdin', spec=StringIO) as stdin:
            os_open.side_effect = IOError
            stdin.fileno.side_effect = AttributeError
            with support.captured_stderr() as stderr:
                with self.assertWarns(getpass.GetPassWarning):
                    getpass.unix_getpass()
            stdin.readline.assert_called_once_with()
            self.assertIn('Warning', stderr.getvalue())
            self.assertIn('Password:', stderr.getvalue()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_getpass.py

示例6: getpassword

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import unix_getpass [as 别名]
def getpassword(prompt):
	if platform.system() == "Linux":
		return getpass.unix_getpass(prompt=prompt)
	elif platform.system() == "Windows" or platform.system() == "Microsoft":
		return getpass.win_getpass(prompt=prompt)
	else:
		return getpass.getpass(prompt=prompt) 
开发者ID:CiscoUcs,项目名称:UcsPythonSDK,代码行数:9,代码来源:method.py

示例7: getpassword

# 需要导入模块: import getpass [as 别名]
# 或者: from getpass import unix_getpass [as 别名]
def getpassword(prompt):
    if platform.system() == "Linux":
        return getpass.unix_getpass(prompt=prompt)
    elif platform.system() == "Windows" or platform.system() == "Microsoft":
        return getpass.win_getpass(prompt=prompt)
    else:
        return getpass.getpass(prompt=prompt) 
开发者ID:CiscoUcs,项目名称:UcsPythonSDK,代码行数:9,代码来源:filters.py


注:本文中的getpass.unix_getpass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。