mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-01 08:51:44 +08:00
TST: Cleaned up test references to adjustments db
If we don't clean them up, then windows can delete the temp dir with the db.
This commit is contained in:
+15
-7
@@ -1081,10 +1081,10 @@ class TestBeforeTradingStart(TestCase):
|
||||
cls.trading_days[-1], 2, 50
|
||||
)
|
||||
|
||||
cls.minute_reader = BcolzMinuteBarReader(cls.tempdir.path)
|
||||
cls.adj_reader = cls.create_adjustments_reader()
|
||||
minute_reader = BcolzMinuteBarReader(cls.tempdir.path)
|
||||
adj_reader = cls.create_adjustments_reader()
|
||||
|
||||
cls.daily_path = cls.tempdir.getpath("testdaily.bcolz")
|
||||
daily_path = cls.tempdir.getpath("testdaily.bcolz")
|
||||
dfs = {
|
||||
1: create_daily_df_for_asset(cls.env, cls.trading_days[0],
|
||||
cls.trading_days[-1]),
|
||||
@@ -1094,7 +1094,7 @@ class TestBeforeTradingStart(TestCase):
|
||||
cls.trading_days[-1])
|
||||
}
|
||||
daily_writer = DailyBarWriterFromDataFrames(dfs)
|
||||
daily_writer.write(cls.daily_path, cls.trading_days, dfs)
|
||||
daily_writer.write(daily_path, cls.trading_days, dfs)
|
||||
|
||||
cls.sim_params = SimulationParameters(
|
||||
period_start=cls.trading_days[1],
|
||||
@@ -1105,9 +1105,9 @@ class TestBeforeTradingStart(TestCase):
|
||||
|
||||
cls.data_portal = DataPortal(
|
||||
env=cls.env,
|
||||
equity_daily_reader=BcolzDailyBarReader(cls.daily_path),
|
||||
equity_minute_reader=cls.minute_reader,
|
||||
adjustment_reader=cls.adj_reader
|
||||
equity_daily_reader=BcolzDailyBarReader(daily_path),
|
||||
equity_minute_reader=minute_reader,
|
||||
adjustment_reader=adj_reader
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -1147,6 +1147,8 @@ class TestBeforeTradingStart(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.env
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
def test_data_in_bts_minute(self):
|
||||
@@ -1478,6 +1480,7 @@ class TestAlgoScript(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.env
|
||||
cls.tempdir.cleanup()
|
||||
teardown_logger(cls)
|
||||
@@ -1867,6 +1870,7 @@ class TestGetDatetime(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.env
|
||||
teardown_logger(cls)
|
||||
cls.tempdir.cleanup()
|
||||
@@ -1946,6 +1950,7 @@ class TestTradingControls(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.env
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@@ -2362,6 +2367,7 @@ class TestAccountControls(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.env
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@@ -2529,6 +2535,7 @@ class TestFutureFlip(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@skip
|
||||
@@ -2648,6 +2655,7 @@ class TestOrderCancelation(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -164,6 +164,11 @@ class TestAPIShim(TestCase):
|
||||
env=cls.env
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.adj_reader
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@classmethod
|
||||
def build_daily_data(cls):
|
||||
path = cls.tempdir.getpath("testdaily.bcolz")
|
||||
@@ -217,10 +222,6 @@ class TestAPIShim(TestCase):
|
||||
|
||||
return SQLiteAdjustmentReader(path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
def setUp(self):
|
||||
self.data_portal = DataPortal(
|
||||
self.env,
|
||||
@@ -229,6 +230,9 @@ class TestAPIShim(TestCase):
|
||||
adjustment_reader=self.adj_reader
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
del self.data_portal
|
||||
|
||||
@classmethod
|
||||
def create_algo(cls, code, filename=None, sim_params=None):
|
||||
if sim_params is None:
|
||||
|
||||
@@ -131,6 +131,8 @@ class TestMinuteBarData(TestBarDataBase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.adjustments_reader
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@classmethod
|
||||
@@ -564,6 +566,8 @@ class TestDailyBarData(TestBarDataBase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.adjustments_reader
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -100,6 +100,7 @@ class TestBenchmark(TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.data_portal
|
||||
del cls.env
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
|
||||
+20
-19
@@ -108,11 +108,18 @@ class HistoryTestCaseBase(TestCase):
|
||||
|
||||
cls.create_data()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
del cls.adj_reader
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
def setUp(self):
|
||||
self.create_data_portal()
|
||||
|
||||
@classmethod
|
||||
def create_data_portal(cls):
|
||||
def tearDown(self):
|
||||
del self.data_portal
|
||||
|
||||
def create_data_portal(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
@classmethod
|
||||
@@ -169,10 +176,6 @@ class HistoryTestCaseBase(TestCase):
|
||||
}
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tempdir.cleanup()
|
||||
|
||||
@classmethod
|
||||
def create_adjustments_reader(cls):
|
||||
path = cls.tempdir.getpath("test_adjustments.db")
|
||||
@@ -470,12 +473,11 @@ MINUTE_FIELD_INFO = {
|
||||
|
||||
|
||||
class MinuteEquityHistoryTestCase(HistoryTestCaseBase):
|
||||
@classmethod
|
||||
def create_data_portal(cls):
|
||||
cls.data_portal = DataPortal(
|
||||
cls.env,
|
||||
equity_minute_reader=BcolzMinuteBarReader(cls.tempdir.path),
|
||||
adjustment_reader=cls.adj_reader
|
||||
def create_data_portal(self):
|
||||
self.data_portal = DataPortal(
|
||||
self.env,
|
||||
equity_minute_reader=BcolzMinuteBarReader(self.tempdir.path),
|
||||
adjustment_reader=self.adj_reader
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -1016,15 +1018,14 @@ class MinuteEquityHistoryTestCase(HistoryTestCaseBase):
|
||||
|
||||
|
||||
class DailyEquityHistoryTestCase(HistoryTestCaseBase):
|
||||
@classmethod
|
||||
def create_data_portal(cls):
|
||||
daily_path = cls.tempdir.getpath("testdaily.bcolz")
|
||||
def create_data_portal(self):
|
||||
daily_path = self.tempdir.getpath("testdaily.bcolz")
|
||||
|
||||
cls.data_portal = DataPortal(
|
||||
cls.env,
|
||||
self.data_portal = DataPortal(
|
||||
self.env,
|
||||
equity_daily_reader=BcolzDailyBarReader(daily_path),
|
||||
equity_minute_reader=BcolzMinuteBarReader(cls.tempdir.path),
|
||||
adjustment_reader=cls.adj_reader
|
||||
equity_minute_reader=BcolzMinuteBarReader(self.tempdir.path),
|
||||
adjustment_reader=self.adj_reader
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user