@@ -263,21 +263,29 @@ def test_doctests(self):
263263 name = test .name
264264 assert name .startswith ("TutorialDocTestHolder.doctest_" )
265265 failures .append (name [30 :])
266- # raise ValueError("Tutorial doctest %s failed" % test.name[30:])
267266 if failures :
268267 raise ValueError (
269268 "%i Tutorial doctests failed: %s" % (len (failures ), ", " .join (failures ))
270269 )
271270
272271 def tearDown (self ):
273- os .chdir (original_path )
274- # files currently don't get created during test with python3.5 and pypy
275- # remove files created from chapter_phylo.tex
276- delete_phylo_tutorial = ["examples/tree1.nwk" , "examples/other_trees.xml" ]
272+ # make sure we are in the tutorial base directory
273+ os .chdir (tutorial_base )
274+
275+ # clean up files created in chapter_phylo.rst
276+ tutorial_phylo_base = os .path .abspath (".." )
277+
278+ delete_phylo_tutorial = [
279+ "tree1.nwk" ,
280+ "tree1.xml" ,
281+ "other_trees.xml" ,
282+ "other_trees.nex" ,
283+ ]
284+
277285 for file in delete_phylo_tutorial :
278- if os .path .exists (os .path .join (tutorial_base , file )):
279- os .remove (os .path .join (tutorial_base , file ))
280- # remove files created from chapter_cluster.tex
286+ if os .path .exists (os .path .join (tutorial_phylo_base , file )):
287+ os .remove (os .path .join (tutorial_phylo_base , file ))
288+ # clean up files created in chapter_cluster.rst
281289 tutorial_cluster_base = os .path .abspath ("../Tests/" )
282290 delete_cluster_tutorial = [
283291 "Cluster/cyano_result.atr" ,
@@ -290,19 +298,11 @@ def tearDown(self):
290298 for file in delete_cluster_tutorial :
291299 if os .path .exists (os .path .join (tutorial_cluster_base , file )):
292300 os .remove (os .path .join (tutorial_cluster_base , file ))
301+ # reset back to the original directory
302+ os .chdir (original_path )
293303
294304
295305# This is to run the doctests if the script is called directly:
296306if __name__ == "__main__" :
297- if missing_deps :
298- print ("Skipping tests needing the following:" )
299- for dep in sorted (missing_deps ):
300- print (f" - { dep } " )
301- print ("Running Tutorial doctests..." )
302- with warnings .catch_warnings ():
303- warnings .simplefilter ("ignore" , BiopythonDeprecationWarning )
304- warnings .simplefilter ("ignore" , BiopythonExperimentalWarning )
305- tests = doctest .testmod (optionflags = doctest .ELLIPSIS )
306- if tests .failed :
307- raise RuntimeError ("%i/%i tests failed" % tests )
308- print ("Tests done" )
307+ runner = unittest .TextTestRunner (verbosity = 2 )
308+ unittest .main (testRunner = runner )
0 commit comments