Question: I've spent hours researching this problem, and I'm still baffled. Please find my ignorance charming.

I'm building a python program that will allow me to pit two AIs against each other in a game of battleship.

Here's my directory structure:

```
.
├── ais_play_battleship
│   ├── game.py
│   ├── __init__.py
│   ├── player.py
│   └── ship.py
├── LICENSE
├── README.md
└── tests
    └── ship_test.py

2 directories, 7 files

```

Currently, I'm trying to write `ship_test.py`, but I cannot seem to import `ais_play_battleship.ship`. I get the dreaded "ModuleNotFoundError"

Here's what my research has taught me about my problem: 

* If you want to import python code from another directory, you should make that directory a package instead of a module. Therefore, I've placed an `__init__.py` file in the root of `ais_play_battleship`.
* Python will only search the directory python is launched from as well as the directory of the script you're running. Therefore, I've been trying to launch my tests by running `python3 tests/ship_tests.py` from the root directory.

Here are my specific questions:

* Why is the error a "ModuleNotFound" error? Shouldn't it be "PackageNotFound"?
* Am I correct to make ais\_play\_battleship a package?
* How can I keep my tests in a separate directory and still use the code in ais\_play\_battleship?

Please forgive me, as I'm not very good at asking questions on StackOverflow. Please tell me how I can improve.

Answer: 
To solve this problem without relying on hacking about your `sys.path`, create a setup.py file and as a build step for your test runner, have it run `pip install .` first. You might want to use a tool like `tox`.

In the top level directory:

setup.py

```
from setuptools import setup

setup(name='ais_play_battleship')

```

tox.ini

```
[tox]
envlist = py36, py37

[testenv]
deps=pytest
commands=
    pip install . --quiet
py.test -q

```

then run your tests (in this example we use tox to do this so that we can also configure how the test environment can be configured) : `tox`
Run `tests/ship_test.py` as a module

```
python -m tests.ship_test

```