@@ -824,19 +824,30 @@ def next(self):
824
824
Backtest (GOOG .iloc [:20 ], S ).run ()
825
825
826
826
827
- @unittest .skipUnless (
828
- os .path .isdir (os .path .join (os .path .dirname (__file__ ),
829
- '..' , '..' , 'doc' )),
830
- "docs dir doesn't exist" )
831
827
class TestDocs (TestCase ):
828
+ DOCS_DIR = os .path .join (os .path .dirname (__file__ ), '..' , '..' , 'doc' )
829
+
830
+ @unittest .skipUnless (os .path .isdir (DOCS_DIR ), "docs dir doesn't exist" )
832
831
def test_examples (self ):
833
- examples = glob (os .path .join (os .path .dirname (__file__ ),
834
- '..' , '..' , 'doc' , 'examples' , '*.py' ))
832
+ examples = glob (os .path .join (self .DOCS_DIR , 'examples' , '*.py' ))
835
833
self .assertGreaterEqual (len (examples ), 4 )
836
834
with chdir (gettempdir ()):
837
835
for file in examples :
838
836
run_path (file )
839
837
838
+ def test_backtest_run_docstring_contains_stats_keys (self ):
839
+ stats = Backtest (SHORT_DATA , SmaCross ).run ()
840
+ for key in stats .index :
841
+ self .assertIn (key , Backtest .run .__doc__ )
842
+
843
+ def test_readme_contains_stats_keys (self ):
844
+ with open (os .path .join (os .path .dirname (__file__ ),
845
+ '..' , '..' , 'README.md' )) as f :
846
+ readme = f .read ()
847
+ stats = Backtest (SHORT_DATA , SmaCross ).run ()
848
+ for key in stats .index :
849
+ self .assertIn (key , readme )
850
+
840
851
841
852
if __name__ == '__main__' :
842
853
warnings .filterwarnings ('error' )
0 commit comments