projectname/ [1]
├── projectname [2]
│ ├── __init__.py
├── README.md
├── setup.py
├── tests
│ └── test_projectname.py
└── tox.ini
- These names all match
- git repository
- repository directory [1]
- python project [2]
- The repository directory contains
- no
__init__.py
setup.py
tox.ini
README.md
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="projectname",
version="0.0.1",
author="John Doe",
author_email='[email protected]',
description="My short description",
extras_require={
"test": [
"pytest",
"pytest-cov",
"pytest-clarity",
'mock;python_version<"3.3"']
},
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=["PyYAML", "other_packages"],
url="https://github.com/gene1wood/projectname",
packages=setuptools.find_packages(),
classifiers=[
"Development Status :: 3 - Alpha",
],
)
- The
extra_require
field sets a custom target called test
. test
is not a reserved word
- This is used in
tox.ini
to install pytest
pytest-clarity
improves readability of pytest diff output
[tox]
envlist = py27, py37, flake8
[travis]
python =
3.7: py37
2.7: py27
[testenv:flake8]
basepython = python
deps = flake8
commands = flake8 projectname tests setup.py
[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps = .[test]
commands =
python -m pytest -vv --cov=projectname {posargs}
from projectname import main
def test_projectname():
assert 1 == 1
- It's possible to import
projectname
because we're calling pytest with python -m pytest
which adds the repository directory to sys.path