question about saunter's PYTHONPATH

7 views
Skip to first unread message

mam-p

unread,
May 22, 2013, 6:53:25 PM5/22/13
to Saunter

I just finished solving what seemed like a bizarre problem. My
PYTHONPATH was set to:

../common:..

I was running pysaunter from /Users/mmaypump/Desktop/PYSAUNTER-678/WD

Several tests were failing with this error....

AttributeError: 'module' object has no attribute
'extract_change_password_link'

But that method did indeed exist in /Users/mmaypump/Desktop/
PYSAUNTER-678/common/extract.py, which had been imported to the PO
file that called extract_change_password_link() via this statement....

import helpers, retrieve, extract

What I figured out with pdb's help is that the extract module being
used was a very old one that had been left laying around in /Users/
mmaypump/Desktop. Since that dir wasn't on the PYTHONPATH set by me,
I'm left wondering....

What PYTHONPATH (or equivalent) is pysaunter using so that I'm careful
not to leave files in those locations in the future?

--mam-p

Adam Goucher

unread,
May 22, 2013, 8:54:05 PM5/22/13
to sau...@googlegroups.com
The only place the path is modified is in conftest.py;

def pytest_configure(config):
    sys.path.append(os.path.join(os.getcwd(), "modules"))

Now because it is an append, if you have modified your PYTHONPATH environment variable in some other way it will take precedence. To debug things you can print sys.path in that function. It prints a heck of a lot of stuff though.

Also, be careful of *.pyc files in your directories. It is possible that an extract.pyc got checked in / moved to your current directory from the former and the interpreter thought it was current so didn't recompile it for you with the method you are looking for. Depending on what version control you are using it will be slightly different, but you should prevent the following from being in version control
- *.pyc
- logs/*
- conf/*.ini (soon to be *.yaml)

-adam
Reply all
Reply to author
Forward
0 new messages