Repository: jwbargsten/pytest-archon (language: python)

Issue:
[Packaging Issue] Tests folder is packaged with pytest-archon
Seems like tests directory is packaged with library, you probably should limit published directories to `pytest_archon`, I discovered a similar issue with my library: https://gitlab.com/ThirVondukr/aioinject/-/blob/96d5c288b8cf6de07a12b1ab4aa2a22800997b54/pyproject.toml#L45
![image](https://github.com/jwbargsten/pytest-archon/assets/50728601/2cd2ddb0-d3d1-4149-a239-691d459861c9)

*Clarification: It's not a problem that it's packaged with the library but it's considered a source directory and is importable


Discussion / hints:
I think I'll leave it like this. The `tests/` folder is added by [setuptools by default](https://github.com/pypa/setuptools/blob/e92440ad6210b21f3ede64d7eb69dead94b37d3a/setuptools/_distutils/command/sdist.py#L237) and my approach is: leave it at default if there is no strong indication that it needs to be changed. Most packages include tests in their source distributions.
The issue is it's importable with just `import tests` 👀 
Then I need more details:
* how do you download it
* how do you install it
* example script where you can import it as "tests", is your script in the same directory as the source?
- Create a venv
- Activate it
- Install pytest-archon with `pip install pytest_archon`
```py
(.venv)
doctor@main MINGW64 /c/dev/pytest-archon-test
$ python
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytest_archon
>>> import tests
>>> dir(tests)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> from tests import test_collect
>>> print(test_collect)
<module 'tests.test_collect' from 'C:\\dev\\pytest-archon-test\\.venv\\Lib\\site-packages\\tests\\test_collect.py'>
```
Directory is completely empty (except for `.venv` directory)

Fix patch:
diff --git a/MANIFEST.in b/MANIFEST.in
index da2bf01..0aeb245 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,5 @@
 exclude .*
 prune .github
 include Makefile
-recursive-include pytest_archon *.txt
-include pytest_archon/py.typed
+recursive-include src/pytest_archon *.txt
+include src/pytest_archon/py.typed
diff --git a/Makefile b/Makefile
index b166d2b..c9c7f16 100644
--- a/Makefile
+++ b/Makefile
@@ -11,10 +11,10 @@ test: $(VENV)/init ## run pytest
 	. $(VENV)/bin/activate && pytest -rA -vvs --log-level INFO
 
 cov: $(VENV)/init ## run pytest
-	. $(VENV)/bin/activate && coverage run --source=pytest_archon --module pytest && coverage report
+	. $(VENV)/bin/activate && coverage run --module pytest && coverage report
 
 lint: $(VENV)/init ## run flake8 to check the code
-	. $(VENV)/bin/activate && flake8 pytest_archon tests && mypy -m pytest_archon
+	. $(VENV)/bin/activate && flake8 src/ tests/ && mypy -m pytest_archon
 
 install-editable: $(VENV)/init
 	. $(VENV)/bin/activate && $(PIP) install -e '.[dev]'
@@ -23,10 +23,10 @@ install: $(VENV)/init
 	. $(VENV)/bin/activate && $(PIP) install '.[dev]'
 
 fmt: $(VENV)/init ## run black to format the code
-	. $(VENV)/bin/activate && black pytest_archon tests
+	. $(VENV)/bin/activate && black src/ tests/
 
 fmt-check: $(VENV)/init ## run black to format the code
-	. $(VENV)/bin/activate && black --check pytest_archon tests
+	. $(VENV)/bin/activate && black --check src/ tests/
 
 clean:
 	rm -rf dist/ build/ *.egg-info
diff --git a/pyproject.toml b/pyproject.toml
index 70c4d97..393ee3e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -44,9 +44,6 @@ dev = [
 
 [tool.setuptools_scm]
 
-[tool.setuptools.packages.find]
-namespaces = true
-
 [tool.setuptools.package-data]
 "pytest_archon.assets" = ["*.txt"]
 
@@ -58,9 +55,10 @@ profile = "black"
 line_length = 110
 
 [tool.pytest.ini_options]
-addopts = [
-    "--import-mode=importlib",
-]
+pythonpath = [ "src", "tests" ]
 
 [project.entry-points.pytest11]
 arch = "pytest_archon.plugin"
+
+[tool.coverage.paths]
+source = ["src"]


Test patch:
diff --git a/pytest_archon/__init__.py b/src/pytest_archon/__init__.py
similarity index 100%
rename from pytest_archon/__init__.py
rename to src/pytest_archon/__init__.py
diff --git a/pytest_archon/assets/core-module-lists/3.6.txt b/src/pytest_archon/assets/core-module-lists/3.6.txt
similarity index 100%
rename from pytest_archon/assets/core-module-lists/3.6.txt
rename to src/pytest_archon/assets/core-module-lists/3.6.txt
diff --git a/pytest_archon/assets/core-module-lists/3.7.txt b/src/pytest_archon/assets/core-module-lists/3.7.txt
similarity index 100%
rename from pytest_archon/assets/core-module-lists/3.7.txt
rename to src/pytest_archon/assets/core-module-lists/3.7.txt
diff --git a/pytest_archon/assets/core-module-lists/3.8.txt b/src/pytest_archon/assets/core-module-lists/3.8.txt
similarity index 100%
rename from pytest_archon/assets/core-module-lists/3.8.txt
rename to src/pytest_archon/assets/core-module-lists/3.8.txt
diff --git a/pytest_archon/assets/core-module-lists/3.9.txt b/src/pytest_archon/assets/core-module-lists/3.9.txt
similarity index 100%
rename from pytest_archon/assets/core-module-lists/3.9.txt
rename to src/pytest_archon/assets/core-module-lists/3.9.txt
diff --git a/pytest_archon/collect.py b/src/pytest_archon/collect.py
similarity index 100%
rename from pytest_archon/collect.py
rename to src/pytest_archon/collect.py
diff --git a/pytest_archon/core_modules.py b/src/pytest_archon/core_modules.py
similarity index 100%
rename from pytest_archon/core_modules.py
rename to src/pytest_archon/core_modules.py
diff --git a/pytest_archon/failure.py b/src/pytest_archon/failure.py
similarity index 100%
rename from pytest_archon/failure.py
rename to src/pytest_archon/failure.py
diff --git a/pytest_archon/plugin.py b/src/pytest_archon/plugin.py
similarity index 100%
rename from pytest_archon/plugin.py
rename to src/pytest_archon/plugin.py
diff --git a/pytest_archon/py.typed b/src/pytest_archon/py.typed
similarity index 100%
rename from pytest_archon/py.typed
rename to src/pytest_archon/py.typed
diff --git a/pytest_archon/rule.py b/src/pytest_archon/rule.py
similarity index 100%
rename from pytest_archon/rule.py
rename to src/pytest_archon/rule.py