Move imports outside of test method code
Closes #266
On second inspection, there are still some cases in the content where import statements are within code snippets, namely
21-automatically-testing-software.md.@johnnonweiler if you give me permission to add commits like this then I can add the subsequent changes needed.
Ah, I just realised that I can actually make edits to this PR directly, so no need to do the step in the link I sent.
Okay, I think I did a good enough regex search to get all the instances of modules being imported inside of a test function. Because this change expanded beyond what I initially thought it would be, we likely need to verify that all or most of the code snippet changed actually still run properly. I don't have the time for that at the moment, however, we will be running the course again at UKAEA, so we could be the test subjects.
Looks good, we'll just need to verify these changes then. After discussion with Aleks, due to time constraints, retiring this PR for now until the material is transitioned to the new Carpentries format, when we'll recreate it and can work on it from there.