]> git-server-git.apps.pok.os.sepia.ceph.com Git - remoto.git/commitdiff
tests: add tests for localhost needs_ssh behavior
authorAlfredo Deza <alfredo@deza.pe>
Tue, 12 Feb 2019 14:29:56 +0000 (09:29 -0500)
committerAlfredo Deza <alfredo@deza.pe>
Wed, 13 Feb 2019 20:14:36 +0000 (15:14 -0500)
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
remoto/tests/backends/test_backends.py

index e4d4e718f586ca258142fd54366de4c2aa9353e8..550e7b0436b2cfaba83643db376addc658b40fba 100644 (file)
@@ -1,6 +1,6 @@
 import sys
 from mock import Mock, patch
-from py.test import raises
+import pytest
 from remoto import backends
 from remoto.tests import fake_module
 from remoto.tests.conftest import Capture, Factory
@@ -31,6 +31,10 @@ class TestNeedsSsh(object):
         socket = FakeSocket('foo', getfqdn='foo.example.org')
         assert backends.needs_ssh('foo.example.org', socket) is False
 
+    @pytest.mark.parametrize('hostname', ['localhost', '127.0.0.1', '127.0.1.1'])
+    def test_local_hostname(self, hostname):
+        assert backends.needs_ssh(hostname) is False
+
 
 class FakeGateway(object):
 
@@ -91,7 +95,7 @@ class TestLegacyModuleExecuteGetAttr(object):
         self.remote_module = backends.LegacyModuleExecute(FakeGateway(), None)
 
     def test_raise_attribute_error(self):
-        with raises(AttributeError) as err:
+        with pytest.raises(AttributeError) as err:
             self.remote_module.foo()
         assert err.value.args[0] == 'module None does not have attribute foo'