Maverick Maverick - 1 month ago 5
Python Question

Why is my python package not discovering the class for unit testing?

May be lame question for many of you smart people out there, but I am struggling with a simple python package creation.
My dir structure for package is :

address-book/
├── __init__.py
├── dist
│   └── book-0.1.tar.gz
├── address-book
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── person.py
│   └── person.pyc
├── address_book.egg-info
│   ├── PKG-INFO
│   ├── SOURCES.txt
│   ├── dependency_links.txt
│   ├── not-zip-safe
│   └── top_level.txt
├── setup.py
└── tests
├── __init__.py
├── __init__.pyc
├── person_test.py
└── person_test.pyc


The setup.py is as follows:

from setuptools import setup, find_packages

setup(name='address-book',
version='0.1',
description='The funniest joke in the world',
url='http://github.com/storborg/funniest',
author='Address Book',
author_email='flyingcircus@example.com',
license='MIT',
packages=find_packages('.'),
test_suite="tests",
zip_safe=False)


The SOURCES.txt:

setup.py
address-book/__init__.py
address-book/person.py
address_book.egg-info/PKG-INFO
address_book.egg-info/SOURCES.txt
address_book.egg-info/dependency_links.txt
address_book.egg-info/not-zip-safe
address_book.egg-info/top_level.txt
tests/__init__.py
tests/person_test.py


In the person_test.py I am not able to import person.py, what could be the reason?

Answer

It looks like you have address-book and address_book.egg-info. I think it should be address-book.egg-info.