diff --git a/tests/test_exception_handling.py b/tests/test_exception_handling.py index 6d3a3ff8..0778a037 100644 --- a/tests/test_exception_handling.py +++ b/tests/test_exception_handling.py @@ -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")', diff --git a/tests/test_finance.py b/tests/test_finance.py index 0badbdd6..3ac50997 100644 --- a/tests/test_finance.py +++ b/tests/test_finance.py @@ -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) diff --git a/tests/test_monitor.py b/tests/test_monitor.py index be381135..5f55aaee 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -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' diff --git a/tests/test_optimize.py b/tests/test_optimize.py index 256ee20c..d571041c 100644 --- a/tests/test_optimize.py +++ b/tests/test_optimize.py @@ -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) diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 1fec3e7a..1fe1ce3c 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -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()