title: Testing student scripts in Python 3
body: <p>I am a teacher in a secondary school and have been using Python to solve simple tasks for several years. I am interesting in writing automated tests to run on students code to automate the marking process.</p>
  
  <p>I've also been interested in TFD so unit testing seems a natural avenue to explore. I have written a test where I ask students to modify several functions and procedures within a script. I can then manually run a test script against each submission to give them a score by importing there file.</p>
  
  <p>Know the crunch...
  I'm struggling to write a script that will iterate through a sub-folder system to run my test script against all submissions. As you can imagine this would be a significant help in reducing marking time.</p>
  
  <p>The folder structure is generated by the way they submit their work electronically. I end up with an assignment folder and then a sub-folder inside this with the students work.
  e.g. "Assignment 1 Folder" and then inside that a folder for each student who submitted e.g. "Anthony Student Folder", "Another Student Folder" etc (About 23 students).</p>
  
  <p>Each student will edit a script that asks them to write a function or a procedure. Here is an example:</p>
  
  <pre><code># =======================================================================
  # Test 1  
  # Write a function called 'MyCubed' that takes an integer number as an
  # argument and returns the cube of that number.  E.g. calling it with 2
  # should give 8.
  # =======================================================================
  # Code HERE the following code is a student response.  
  def MyCubed(num):  
      return num**3
  </code></pre>
  
  <p>So I've created a testing file that I can put in each students folder and run to test each file.</p>
  
  <pre><code># =======================================================================
  # Test 1  
  # Cube an integer  
  test1 = 0  
  ModuleExist = True  
  try:  
      test1 = Python_Test.MyCubed(3) 
  except:  
      print('\nTest 1: Failed: MyCubed not present')  
      ModuleExist = False  
  if ModuleExist:  
      if test1 == 27:  
          print('\nTest 1: My Cubed Passed')
          score += 10
      elif test1 != 0:
          print('\nTest 1: Failed expected 27, actually-', test1)
  </code></pre>
  
  <p>This script contains 8 tests (modules) to tested/run on the scripts. 
  So I was hoping to iterate through the list of student folders and import that students solution and run with test case.</p>
  
  <p>I can put the file in each folder and run them individually but I'd like to automate it to iterate through all the sub-folders.</p>