示例#1
0
 def test_compare_two_equal_instances(self):
     """Make sure we can compare instances"""
     a = ioutils.SpooledStringIO()
     a.write(u"I am equal!")
     b = ioutils.SpooledStringIO()
     b.write(u"I am equal!")
     self.assertEqual(a, b)
示例#2
0
 def test_compare_not_equal_instances(self):
     """Make sure instances with different values fail == check."""
     a = ioutils.SpooledStringIO()
     a.write(u"I am a!")
     b = ioutils.SpooledStringIO()
     b.write(u"I am b!")
     self.assertNotEqual(a, b)
示例#3
0
 def test_compare_different_instances(self):
     """Make sure two different instance types are not considered equal"""
     a = ioutils.SpooledBytesIO()
     a.write(binary_type(b"I am equal!"))
     b = ioutils.SpooledStringIO()
     b.write(text_type("I am equal!"))
     self.assertNotEqual(a, b)
示例#4
0
 def test_use_as_context_mgr(self):
     """Make sure SpooledStringIO can be used as a context manager"""
     test_str = u"Armado en los EE, UU. para S. P. Richards co.,"
     with ioutils.SpooledStringIO() as f:
         f.write(test_str)
         self.assertEqual(f.getvalue(), test_str)
示例#5
0
 def test_auto_rollover(self):
     """Make sure file rolls over to disk after max_size reached"""
     tmp = ioutils.SpooledStringIO(max_size=10)
     tmp.write(u"The quick brown fox jumped over the lazy dogs.")
     self.assertTrue(tmp._rolled)
示例#6
0
 def setUp(self):
     self.spooled_flo = ioutils.SpooledStringIO()
     self.test_str = u"Remember kids, always use an emdash: '\u2014'"
     self.test_str_lines = u"Text with\u2014{0}newlines!".format(os.linesep)
     self.data_type = text_type