Example #1
0
 def test_memory(self):
     # make sure the memory occupation is low
     # (to protect against bad refactoring of the XMLWriter)
     proc = psutil.Process(os.getpid())
     try:
         rss = memory_info(proc).rss
     except psutil.AccessDenied:
         raise unittest.SkipTest('Memory info not accessible')
     devnull = open(os.devnull, 'wb')
     with StreamingXMLWriter(devnull) as writer:
         for asset in assetgen(1000):
             writer.serialize(asset)
     allocated = memory_info(proc).rss - rss
     self.assertLess(allocated, 204800)  # < 200 KB
Example #2
0
 def test_memory(self):
     # make sure the memory occupation is low
     # (to protect against bad refactoring of the XMLWriter)
     try:
         import psutil
     except ImportError:
         raise unittest.SkipTest('psutil not installed')
     proc = psutil.Process(os.getpid())
     try:
         rss = memory_info(proc).rss
     except psutil.AccessDenied:
         raise unittest.SkipTest('Memory info not accessible')
     devnull = open(os.devnull, 'w')
     with StreamingXMLWriter(devnull) as writer:
         for asset in assetgen(1000):
             writer.serialize(asset)
     allocated = memory_info(proc).rss - rss
     self.assertLess(allocated, 204800)  # < 200 KB