
import os

import fixtures
import testtools


class TestCase(testtools.TestCase):

    true = ('True', 'true', '1', 'yes')

    def setUp(self):
        super(TestCase, self).setUp()
        if os.environ.get('OS_STDOUT_CAPTURE') in self.true:
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if os.environ.get('OS_STDERR_CAPTURE') in self.true:
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
        if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
            os.environ.get('OS_LOG_CAPTURE') != '0'):
            self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
                                                   level=None))


import fixtures
import testtools


class TestCase(testtools.TestCase):

    def setUp(self):
        super(TestCase, self).setUp()
        stdout = self.useFixture(fixtures.StringStream('stdout')).stream
        self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        stderr = self.useFixture(fixtures.StringStream('stderr')).stream
        self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
        self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
                                               level=None))

Make unit test attachment fixtures always enabled
Make unit test attachment fixtures always enabled

The code used in the base test class was copied from other projects and
made the stdout, stderr, and logging attachments enabled optionally by
env variables. However there is no reason to do that since if there is
any output it is best to capture it instead of dropping it. This commit
removes the conditionals and always attaches these.

- 
- import os
  
  import fixtures
  import testtools
  
  
  class TestCase(testtools.TestCase):
  
-     true = ('True', 'true', '1', 'yes')
- 
      def setUp(self):
          super(TestCase, self).setUp()
-         if os.environ.get('OS_STDOUT_CAPTURE') in self.true:
-             stdout = self.useFixture(fixtures.StringStream('stdout')).stream
+         stdout = self.useFixture(fixtures.StringStream('stdout')).stream
-             self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
+         self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
-         if os.environ.get('OS_STDERR_CAPTURE') in self.true:
-             stderr = self.useFixture(fixtures.StringStream('stderr')).stream
+         stderr = self.useFixture(fixtures.StringStream('stderr')).stream
-             self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
+         self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
-         if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
-             os.environ.get('OS_LOG_CAPTURE') != '0'):
-             self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
+         self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
-                                                    level=None))
+                                                level=None))
  
Make unit test attachment fixtures always enabled
## Code Before:

import os

import fixtures
import testtools


class TestCase(testtools.TestCase):

    true = ('True', 'true', '1', 'yes')

    def setUp(self):
        super(TestCase, self).setUp()
        if os.environ.get('OS_STDOUT_CAPTURE') in self.true:
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if os.environ.get('OS_STDERR_CAPTURE') in self.true:
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
        if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
            os.environ.get('OS_LOG_CAPTURE') != '0'):
            self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
                                                   level=None))

## Instruction:
Make unit test attachment fixtures always enabled
## Code After:

import fixtures
import testtools


class TestCase(testtools.TestCase):

    def setUp(self):
        super(TestCase, self).setUp()
        stdout = self.useFixture(fixtures.StringStream('stdout')).stream
        self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        stderr = self.useFixture(fixtures.StringStream('stderr')).stream
        self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
        self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
                                               level=None))
