Merge "Move _capture_stdout to a common place"
This commit is contained in:
commit
055e5f437a
|
@ -16,10 +16,12 @@
|
|||
import codecs
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
import fixtures
|
||||
from oslo_config import fixture as config
|
||||
from oslotest import base as test_base
|
||||
from six import moves
|
||||
|
||||
from oslo_policy import _checks
|
||||
from oslo_policy import policy
|
||||
|
@ -52,6 +54,10 @@ class PolicyBaseTestCase(test_base.BaseTestCase):
|
|||
with codecs.open(path, 'w', encoding='utf-8') as f:
|
||||
f.write(contents)
|
||||
|
||||
def _capture_stdout(self):
|
||||
self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO()))
|
||||
return sys.stdout
|
||||
|
||||
|
||||
class FakeCheck(_checks.BaseCheck):
|
||||
def __init__(self, result=None):
|
||||
|
|
|
@ -10,13 +10,10 @@
|
|||
# under the License.
|
||||
|
||||
import operator
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from six import moves
|
||||
import stevedore
|
||||
import testtools
|
||||
|
||||
|
@ -50,10 +47,6 @@ class GenerateSampleYAMLTestCase(base.PolicyBaseTestCase):
|
|||
super(GenerateSampleYAMLTestCase, self).setUp()
|
||||
self.enforcer = policy.Enforcer(self.conf, policy_file='policy.yaml')
|
||||
|
||||
def _capture_stdout(self):
|
||||
self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO()))
|
||||
return sys.stdout
|
||||
|
||||
def test_generate_loadable_yaml(self):
|
||||
extensions = []
|
||||
for name, opts in OPTS.items():
|
||||
|
@ -343,10 +336,6 @@ class GenerateSampleJSONTestCase(base.PolicyBaseTestCase):
|
|||
super(GenerateSampleJSONTestCase, self).setUp()
|
||||
self.enforcer = policy.Enforcer(self.conf, policy_file='policy.json')
|
||||
|
||||
def _capture_stdout(self):
|
||||
self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO()))
|
||||
return sys.stdout
|
||||
|
||||
def test_generate_loadable_json(self):
|
||||
extensions = []
|
||||
for name, opts in OPTS.items():
|
||||
|
@ -530,10 +519,6 @@ class ListRedundantTestCase(base.PolicyBaseTestCase):
|
|||
def setUp(self):
|
||||
super(ListRedundantTestCase, self).setUp()
|
||||
|
||||
def _capture_stdout(self):
|
||||
self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO()))
|
||||
return sys.stdout
|
||||
|
||||
def test_matched_rules(self):
|
||||
extensions = []
|
||||
for name, opts in OPTS.items():
|
||||
|
|
Loading…
Reference in New Issue