summaryrefslogtreecommitdiff
path: root/tests/test_config.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2019-07-02 19:24:01 -0400
committerJeff Forcier <jeff@bitprophet.org>2019-08-26 20:48:25 -0400
commit5a56eed757c598301f1cc1f5a31e9d06aa081ac1 (patch)
treeee5eb8ca70892fb5f934ee61111d1555e4d705b0 /tests/test_config.py
parentc50f825aac15f878647ffb7533fdbe157399ca8b (diff)
downloadparamiko-5a56eed757c598301f1cc1f5a31e9d06aa081ac1.tar.gz
Start moving config snippets to files
Diffstat (limited to 'tests/test_config.py')
-rw-r--r--tests/test_config.py37
1 files changed, 9 insertions, 28 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 903690f7..cecb6204 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -11,34 +11,18 @@ from paramiko.py3compat import StringIO
from paramiko import SSHConfig, SSHConfigDict
from paramiko.util import lookup_ssh_host_config, parse_ssh_config
+from .util import _support
-# Note some lines in this configuration have trailing spaces on purpose
-test_config_file = """\
-Host *
- User robey
- IdentityFile =~/.ssh/id_rsa
-
-# comment
-Host *.example.com
- \tUser bjork
-Port=3333
-Host *
-"""
-
-dont_strip_whitespace_please = "\t \t Crazy something dumb "
-test_config_file += dont_strip_whitespace_please
-test_config_file += """
-Host spoo.example.com
-Crazy something else
-"""
+class TestSSHConfig(object):
+ def setup(self):
+ self.config_flo = open(_support("robey.config"))
+ def teardown(self):
+ self.config_flo.close()
-class TestSSHConfig(object):
def test_parse_config(self):
- global test_config_file
- f = StringIO(test_config_file)
- config = parse_ssh_config(f)
+ config = parse_ssh_config(self.config_flo)
expected = [
{"host": ["*"], "config": {}},
{
@@ -58,9 +42,7 @@ class TestSSHConfig(object):
assert config._config == expected
def test_host_config(self):
- global test_config_file
- f = StringIO(test_config_file)
- config = parse_ssh_config(f)
+ config = parse_ssh_config(self.config_flo)
for host, values in {
"irc.danger.com": {
@@ -267,8 +249,7 @@ IdentityFile something_%l_using_fqdn
assert config.lookup("abcqwerty")["hostname"] == "127.0.0.1"
def test_get_hostnames(self):
- f = StringIO(test_config_file)
- config = parse_ssh_config(f)
+ config = parse_ssh_config(self.config_flo)
expected = {"*", "*.example.com", "spoo.example.com"}
assert config.get_hostnames() == expected