Skip to content
Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:4444864
Created Jan 3, 2013

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
Something went wrong with that request. Please try again.