module import questions and question about pytest and module imports

2014-12-07 Thread sam pendleton
garage/
|- __init__.py
|- cars/
|- __init__.py
|- hummer.py
tests/
|- test_cars.py

at the top of test_cars.py, there is this:
from garage.cars import hummer

pytest is on this import statement, so i guess it's incorrect.

what should it be?

if i open a python repl within tests/, how can i say import hummer.py?

do i need to do anything to make pytest aware of hummer.py?

thanks for the help!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module import questions and question about pytest and module imports

2014-12-08 Thread sam pendleton
Thanks for getting back with me!

On Sun, Dec 7, 2014 at 11:26 AM, Dave Angel  wrote:
> On 12/05/2014 11:50 PM, sam pendleton wrote:
>>
>> garage/
>>  |- __init__.py
>>  |- cars/
>>  |- __init__.py
>>  |- hummer.py
>> tests/
>>  |- test_cars.py
>>
>> at the top of test_cars.py, there is this:
>>  from garage.cars import hummer
>>
>> pytest is on this import statement, so i guess it's incorrect.
>
>
> No idea what that statement is trying to say.

Sorry Dave, I was saying that pytest is hung up there stating it can't
import that module.


> If you're going to import something, it either has to be on the sys.path, or
> in the current directory.  Is garage/ on your sys.path?
>
> You can examine sys.path  by
>import sys
>print(sys.path)

Having to put the garage package on the sys.path seems a little off,
why wouldn't relative imports work?

Do most people somehow put their packages in sys.path when bundling
their python packages up to be shared with setuptools or other python
package managers? If so, how?
-- 
https://mail.python.org/mailman/listinfo/python-list