Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kubernetes/base/config/exec_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def __init__(self, exec_config, cwd):
value = item['value']
additional_vars[name] = value
self.env.update(additional_vars)

self.cwd = cwd or None

def run(self, previous_response=None):
is_interactive = sys.stdout.isatty()
is_interactive = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
kubernetes_exec_info = {
'apiVersion': self.api_version,
'kind': 'ExecCredential',
Expand Down
13 changes: 13 additions & 0 deletions kubernetes/base/config/exec_provider_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ def test_run_in_dir(self, mock):
ep.run()
self.assertEqual(mock.call_args[1]['cwd'], '/some/directory')

@mock.patch('subprocess.Popen')
def test_ok_no_console_attached(self, mock):
instance = mock.return_value
instance.wait.return_value = 0
instance.communicate.return_value = (self.output_ok, '')
mock_stdout = unittest.mock.patch(
'sys.stdout', new=None) # Simulate detached console
with mock_stdout:
ep = ExecProvider(self.input_ok, None)
result = ep.run()
self.assertTrue(isinstance(result, dict))
self.assertTrue('token' in result)


if __name__ == '__main__':
unittest.main()