|
5 | 5 | @author: cheng.li
|
6 | 6 | """
|
7 | 7 |
|
8 |
| -import sys |
9 |
| -import os |
| 8 | +from simpleutils import add_parent_path |
10 | 9 |
|
11 |
| -thisFilePath = os.path.abspath(__file__) |
| 10 | +add_parent_path(__file__, 3) |
12 | 11 |
|
13 |
| -sys.path.append(os.path.sep.join(thisFilePath.split(os.path.sep)[:-3])) |
14 |
| - |
15 |
| -import unittest |
| 12 | +from simpleutils import TestRunner |
| 13 | +from simpleutils import CustomLogger |
16 | 14 | import PyFin.tests.api as api
|
17 | 15 | import PyFin.tests.Analysis as Analysis
|
18 | 16 | import PyFin.tests.DateUtilities as DateUtilities
|
|
23 | 21 | import PyFin.tests.Utilities as Utilities
|
24 | 22 |
|
25 | 23 |
|
26 |
| -def test(): |
27 |
| - print('Python ' + sys.version) |
28 |
| - suite = unittest.TestSuite() |
29 |
| - |
30 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(api.TestDateUtilities) |
31 |
| - suite.addTests(tests) |
32 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TestDataProviders) |
33 |
| - suite.addTests(tests) |
34 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TestSecurityValueHolders) |
35 |
| - suite.addTests(tests) |
36 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TestCrossSectionValueHolder) |
37 |
| - suite.addTests(tests) |
38 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TestSecurityValues) |
39 |
| - suite.addTests(tests) |
40 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TestTransformer) |
41 |
| - suite.addTest(tests) |
42 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TechnicalAnalysis.TestStatelessTechnicalAnalysis) |
43 |
| - suite.addTests(tests) |
44 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TechnicalAnalysis.TestStatelessTechnicalAnalysis) |
45 |
| - suite.addTests(tests) |
46 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Analysis.TechnicalAnalysis.TestStatefulTechnicalAnalysis) |
47 |
| - suite.addTests(tests) |
48 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(DateUtilities.TestCalendar) |
49 |
| - suite.addTests(tests) |
50 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(DateUtilities.TestDate) |
51 |
| - suite.addTests(tests) |
52 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(DateUtilities.TestPeriod) |
53 |
| - suite.addTests(tests) |
54 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(DateUtilities.TestSchedule) |
55 |
| - suite.addTests(tests) |
56 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Env.TestSettings) |
57 |
| - suite.addTests(tests) |
58 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Distributions.TestDistribution) |
59 |
| - suite.addTests(tests) |
60 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(PricingEngines.TestBlackFormula) |
61 |
| - suite.addTests(tests) |
62 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(PricingEngines.TestSabrFormula) |
63 |
| - suite.addTests(tests) |
64 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(PricingEngines.TestSVIInterpolation) |
65 |
| - suite.addTests(tests) |
66 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Accumulators.TestAccumulatorImpl) |
67 |
| - suite.addTests(tests) |
68 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Accumulators.TestAccumulatorsArithmetic) |
69 |
| - suite.addTests(tests) |
70 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Accumulators.TestStatefulAccumulators) |
71 |
| - suite.addTests(tests) |
72 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Accumulators.TestStatelessAccumulators) |
73 |
| - suite.addTests(tests) |
74 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Timeseries.TestNormalizers) |
75 |
| - suite.addTests(tests) |
76 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Accumulators.TestPerformancers) |
77 |
| - suite.addTests(tests) |
78 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Math.Timeseries.TestTimeseries) |
79 |
| - suite.addTests(tests) |
80 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(POpt.TestOptimizer) |
81 |
| - suite.addTests(tests) |
82 |
| - tests = unittest.TestLoader().loadTestsFromTestCase(Utilities.TestAsserts) |
83 |
| - suite.addTests(tests) |
84 |
| - |
85 |
| - res = unittest.TextTestRunner(verbosity=3).run(suite) |
86 |
| - if len(res.errors) >= 1 or len(res.failures) >= 1: |
87 |
| - sys.exit(-1) |
88 |
| - else: |
89 |
| - sys.exit(0) |
90 |
| - |
91 |
| - |
92 | 24 | if __name__ == "__main__":
|
93 |
| - test() |
| 25 | + pyfin_logger = CustomLogger('FINANCE-PYTHON', 'info') |
| 26 | + test_runner = TestRunner([api.TestDateUtilities, |
| 27 | + Analysis.TestDataProviders, |
| 28 | + Analysis.TestSecurityValueHolders, |
| 29 | + Analysis.TestCrossSectionValueHolder, |
| 30 | + Analysis.TestSecurityValues, |
| 31 | + Analysis.TestTransformer, |
| 32 | + Analysis.TechnicalAnalysis.TestStatelessTechnicalAnalysis, |
| 33 | + Analysis.TechnicalAnalysis.TestStatelessTechnicalAnalysis, |
| 34 | + Analysis.TechnicalAnalysis.TestStatefulTechnicalAnalysis, |
| 35 | + DateUtilities.TestCalendar, |
| 36 | + DateUtilities.TestDate, |
| 37 | + DateUtilities.TestPeriod, |
| 38 | + DateUtilities.TestSchedule, |
| 39 | + Env.TestSettings, |
| 40 | + Math.Distributions.TestDistribution, |
| 41 | + PricingEngines.TestBlackFormula, |
| 42 | + PricingEngines.TestSabrFormula, |
| 43 | + PricingEngines.TestSVIInterpolation, |
| 44 | + Math.Accumulators.TestAccumulatorImpl, |
| 45 | + Math.Accumulators.TestAccumulatorsArithmetic, |
| 46 | + Math.Accumulators.TestStatefulAccumulators, |
| 47 | + Math.Accumulators.TestStatelessAccumulators, |
| 48 | + Math.Timeseries.TestNormalizers, |
| 49 | + Math.Accumulators.TestPerformancers, |
| 50 | + Math.Timeseries.TestTimeseries, |
| 51 | + POpt.TestOptimizer, |
| 52 | + Utilities.TestAsserts], |
| 53 | + pyfin_logger) |
| 54 | + test_runner.run() |
| 55 | + |
0 commit comments