Unittest fails to import module

Martin Schöön martin.schoon at gmail.com
Sat Jun 29 17:19:37 EDT 2013


On 2013-06-29, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> On Sat, 29 Jun 2013 19:13:47 +0000, Martin Schöön wrote:
>
>> $PYTHONPATH points at both the code and the test directories.
>> 
>> When I run blablabla_test.py it fails to import blablabla.py
>
> What error message do you get?
>
>  
>> I have messed around for oven an hour and get nowhere. I have done
>> unittesting like this with success in the past and I have revisited one
>> of those projects and it still works there.
> [...]
>> Any leads?
>
> The first step is to confirm that your path is setup correctly. At the 
> very top of blablabla_test, put this code:
>
> import os, sys
> print(os.getenv('PYTHONPATH'))
> print(sys.path)
>
Yes, right, I had not managed to make my change to PYTHONPATH stick.
I said the explanation would be trivial, didn't I?

Thanks for the quick replies. I am back in business now.

No, neither English nor Python are native languages of mine but I
enjoy (ab)using both :-)

/Martin



More information about the Python-list mailing list