示例#1
0
 def test_reduce_file_size_long_line_not_truncated(self):
     with tempfile.NamedTemporaryFile(mode='wt') as tmp:
         content = 'Long line ' * 500
         tmp.write(content)
         tmp.flush()
         runexecutor._reduce_file_size_if_necessary(tmp.name, 500)
         with open(tmp.name, 'rt') as tmp2:
             self.assertMultiLineEqual(tmp2.read(), content)
示例#2
0
 def test_reduce_file_size_long_line_not_truncated(self):
     with tempfile.NamedTemporaryFile(mode="wt") as tmp:
         content = "Long line " * 500
         tmp.write(content)
         tmp.flush()
         runexecutor._reduce_file_size_if_necessary(tmp.name, 500)
         with open(tmp.name, "rt") as tmp2:
             self.assertMultiLineEqual(tmp2.read(), content)
示例#3
0
 def test_reduce_file_size_limit_zero(self):
     with tempfile.NamedTemporaryFile(mode='wt') as tmp:
         line = 'Some text\n'
         tmp.write(line * 500)
         tmp.flush()
         runexecutor._reduce_file_size_if_necessary(tmp.name, 0)
         self.assertLessEqual(os.path.getsize(tmp.name), self.REDUCE_OVERHEAD)
         with open(tmp.name, 'rt') as tmp2:
             new_content = tmp2.read()
     self.assertIn(self.REDUCE_WARNING_MSG, new_content)
     self.assertTrue(new_content.startswith(line))
示例#4
0
 def test_reduce_file_size_limit_zero(self):
     with tempfile.NamedTemporaryFile(mode='wt') as tmp:
         line = 'Some text\n'
         tmp.write(line * 500)
         tmp.flush()
         runexecutor._reduce_file_size_if_necessary(tmp.name, 0)
         self.assertLessEqual(os.path.getsize(tmp.name), self.REDUCE_OVERHEAD)
         with open(tmp.name, 'rt') as tmp2:
             new_content = tmp2.read()
     self.assertIn(self.REDUCE_WARNING_MSG, new_content)
     self.assertTrue(new_content.startswith(line))
示例#5
0
 def test_reduce_file_size(self):
     with tempfile.NamedTemporaryFile(mode="wt") as tmp:
         line = "Some text\n"
         tmp.write(line * 500)
         tmp.flush()
         limit = 500
         runexecutor._reduce_file_size_if_necessary(tmp.name, limit)
         self.assertLessEqual(os.path.getsize(tmp.name),
                              limit + self.REDUCE_OVERHEAD)
         with open(tmp.name, "rt") as tmp2:
             new_content = tmp2.read()
     self.assertIn(self.REDUCE_WARNING_MSG, new_content)
     self.assertTrue(new_content.startswith(line))
     self.assertTrue(new_content.endswith(line))
示例#6
0
 def test_reduce_file_size_empty_file2(self):
     with tempfile.NamedTemporaryFile() as tmp:
         runexecutor._reduce_file_size_if_necessary(tmp.name, 500)
         self.assertEqual(os.path.getsize(tmp.name), 0)
示例#7
0
 def test_reduce_file_size_empty_file2(self):
     with tempfile.NamedTemporaryFile() as tmp:
         runexecutor._reduce_file_size_if_necessary(tmp.name, 500)
         self.assertEqual(os.path.getsize(tmp.name), 0)