@@ -824,19 +824,30 @@ def next(self):
824824 Backtest (GOOG .iloc [:20 ], S ).run ()
825825
826826
827- @unittest .skipUnless (
828- os .path .isdir (os .path .join (os .path .dirname (__file__ ),
829- '..' , '..' , 'doc' )),
830- "docs dir doesn't exist" )
831827class 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" )
832831 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' ))
835833 self .assertGreaterEqual (len (examples ), 4 )
836834 with chdir (gettempdir ()):
837835 for file in examples :
838836 run_path (file )
839837
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+
840851
841852if __name__ == '__main__' :
842853 warnings .filterwarnings ('error' )
0 commit comments