Skip to content

Instantly share code, notes, and snippets.

Created January 3, 2013 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4444864 to your computer and use it in GitHub Desktop.
Save anonymous/4444864 to your computer and use it in GitHub Desktop.
class DeprecationDisplayTest(unittest.TestCase):
# tests for 19546
def setUp(self):
self.new_stderr = StringIO()
self.new_out = StringIO()
self.old_stdout = sys.stdout
self.old_stderr = sys.stderr
sys.stdout = self.new_out
sys.stderr = self.new_stderr
def tearDown(self):
sys.stderr = self.old_stderr
sys.stdout = self.old_stdout
print self.results
def test_warning_output(self):
# sys.stderr.write("blah blah")
warnings.warn("Foo deprecated", DeprecationWarning)
result = force_text(self.new_stderr.getvalue())
resultb = force_text(self.new_stderr.getvalue())
self.results = result + resultb
# fails
self.assertTrue("Foo deprecated" in result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment