Python Import not working at the top of file but works inside function

I was using django and ran into the following problem just wondering why Python orge acts this way. I was importing a function and I had the import at the top of the file with my other imports and my tests keep failing but my tests passes after I move the import statement to inside the function I was working on. Has anyone encountered such problems ?

Could you give a small example of this issue, please?