Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test example in integration testing docs #34307

Merged
merged 1 commit into from
Jun 27, 2016
Merged
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
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