mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #34307 from rallytime/fix-test-example
Fix test example in integration testing docs
This commit is contained in:
commit
91703d2dc4
1 changed files with 13 additions and 4 deletions
|
@ -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
|
||||
'''
|
||||
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue