public
anonymous / gist:4444864
Created

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.