fixed logging for tests

This commit is contained in:
fawce
2012-07-26 18:45:42 -04:00
parent 8a758c1293
commit 83da8d2310
5 changed files with 23 additions and 32 deletions
+10 -16
View File
@@ -54,7 +54,7 @@ class ExceptionTestCase(TestCase):
output, _ = drain_zipline(self, zipline)
self.assertEqual(len(output), 1)
self.assertEqual(output[-1]['prefix'], 'EXCEPTION')
payload = output[-1]['payload']
payload = output[-1]['payload']['stack']
#check(self, payload, INITIALIZE_TB)
self.assertTrue(zipline.sim.ready())
@@ -79,8 +79,8 @@ class ExceptionTestCase(TestCase):
self.assertEqual(len(output), 1)
self.assertEqual(output[-1]['prefix'], 'EXCEPTION')
payload = output[-1]['payload']
#check(self, payload, HANDLE_DATA_TB)
payload = output[-1]['payload']['stack']
check(self, payload, HANDLE_DATA_TB)
self.assertTrue(zipline.sim.ready())
self.assertFalse(zipline.sim.exception)
@@ -124,33 +124,27 @@ INITIALIZE_TB =\
'method': 'initialize'}]
HANDLE_DATA_TB =\
[{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
'line': 'self._run()',
'lineno': 229,
'method': 'run'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
'line': 'self.loop()',
'lineno': 220,
'method': '_run'},
[{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', 'line': 'self._run()', 'lineno': 204, 'method': 'run'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', 'line': 'self.loop()', 'lineno': 195, 'method': '_run'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
'line': 'self.do_work()',
'lineno': 257,
'lineno': 235,
'method': 'loop'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
'line': 'self.process_event(event)',
'lineno': 119,
'lineno': 116,
'method': 'do_work'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
'line': 'self.run_algorithm()',
'lineno': 167,
'lineno': 164,
'method': 'process_event'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
'line': 'self.do_op(self.algorithm.handle_data, data)',
'lineno': 189,
'lineno': 186,
'method': 'run_algorithm'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
'line': 'callable_op(*args, **kwargs)',
'lineno': 208,
'lineno': 206,
'method': 'do_op'},
{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/test_algorithms.py',
'line': 'raise Exception("Algo exception in handle_data")',
+1 -2
View File
@@ -7,7 +7,6 @@ import zmq
from unittest2 import TestCase
from datetime import datetime, timedelta
from collections import defaultdict
from logbook.compat import LoggingHandler
from nose.tools import timed
@@ -47,7 +46,7 @@ class FinanceTestCase(TestCase):
}
self.ctx = zmq.Context()
setup_logger(self)
setup_logger(self, '/var/log/qexec/qexec.log')
def tearDown(self):
teardown_logger(self)
+4 -4
View File
@@ -1,15 +1,15 @@
from logbook.compat import LoggingHandler
from zipline.utils.test_utils import setup_logger, teardown_logger
from unittest2 import TestCase, skip
from zipline.core.monitor import Controller
class TestMonitor(TestCase):
def setUp(self):
self.log_handler = LoggingHandler()
self.log_handler.push_application()
setup_logger(self, '/var/log/qexec/qexec.log')
def tearDown(self):
self.log_handler.pop_application()
teardown_logger(self)
def test_init(self):
pub_socket = 'tcp://127.0.0.1:5000'
+4 -4
View File
@@ -13,7 +13,7 @@ EXTENDED_TIMEOUT = 90
allocator = AddressAllocator(1000)
from logbook.compat import LoggingHandler
from zipline.utils.test_utils import setup_logger, teardown_logger
class TestUpDown(TestCase):
"""This unittest verifies that the BuySellAlgorithm in
@@ -31,11 +31,11 @@ class TestUpDown(TestCase):
'amplitude' : 30,
'base_price' : 50
}
self.log_handler = LoggingHandler()
self.log_handler.push_application()
setup_logger(self, '/var/log/qexec/qexec.log')
def tearDown(self):
self.log_handler.pop_application()
teardown_logger(self)
@skip
@timed(DEFAULT_TIMEOUT)
+4 -6
View File
@@ -2,7 +2,7 @@ from datetime import timedelta
from collections import defaultdict
from unittest2 import TestCase
from logbook.compat import LoggingHandler
from zipline.utils.test_utils import setup_logger, teardown_logger
import zipline.utils.factory as factory
from zipline.finance.vwap import DailyVWAP, VWAPTransform
@@ -25,11 +25,10 @@ class ZiplineWithTransformsTestCase(TestCase):
'sid' : 133,
'devel' : True
}
self.log_handler = LoggingHandler()
self.log_handler.push_application()
setup_logger(self, '/var/log/qexec/qexed.log')
def tearDown(self):
self.log_handler.pop_application()
teardown_logger(self)
def test_vwap_tnfm(self):
zipline = SimulatedTrading.create_test_zipline(
@@ -47,8 +46,7 @@ class FinanceTransformsTestCase(TestCase):
def setUp(self):
self.trading_environment = factory.create_trading_environment()
self.log_handler = LoggingHandler()
self.log_handler.push_application()
setup_logger(self, '/var/log/qexec/qexec.log')
def tearDown(self):
self.log_handler.pop_application()