Skip to content

Commit

Permalink
Merge pull request #34307 from rallytime/fix-test-example
Browse files Browse the repository at this point in the history
Fix test example in integration testing docs
  • Loading branch information
Mike Place committed Jun 27, 2016
2 parents d235b12 + f44a054 commit 91703d2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions doc/topics/development/tests/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,23 @@ to test states:

.. code-block:: python
# Import python libs
from __future__ import absolute_import
import os
import shutil
# Import Salt Testing libs
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import salt libs
import integration
import salt.utils
HFILE = os.path.join(integration.TMP, 'hosts')
class HostTest(integration.ModuleCase):
class HostTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
'''
Validate the host state
'''
Expand All @@ -437,9 +447,8 @@ to test states:
name = 'spam.bacon'
ip = '10.10.10.10'
ret = self.run_state('host.present', name=name, ip=ip)
result = self.state_result(ret)
self.assertTrue(result)
with open(HFILE) as fp_:
self.assertSaltTrueReturn(ret)
with salt.utils.fopen(HFILE) as fp_:
output = fp_.read()
self.assertIn('{0}\t\t{1}'.format(ip, name), output)
Expand Down

0 comments on commit 91703d2

Please sign in to comment.