Repository: etianen/logot (language: python)

Issue:
Using `coverage` directly rather than `pytest-cov`
This allows us to move the `pytest` plugin into the package namespace.

Also switching to `importlib` import mode, following the [pytest recommendations](https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#choosing-a-test-layout-import-rules).


Discussion / hints:

Fix patch:
diff --git a/pyproject.toml b/pyproject.toml
index d30a63a6..417ff007 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,7 +17,7 @@ classifiers = [
     "Topic :: System :: Logging",
     "Typing :: Typed",
 ]
-packages = [{ include = "logot" }, { include = "_logot_pytest.py" }]
+packages = [{ include = "logot" }]
 
 [tool.poetry.dependencies]
 python = "^3.8"
@@ -43,7 +43,7 @@ sphinx = { version = "7.2.6", markers = "python_version >= '3.12'" }
 sphinx-autobuild = { version = "*", markers = "python_version >= '3.12'" }
 
 [tool.poetry.plugins.pytest11]
-logot = "_logot_pytest"
+logot = "logot._pytest"
 
 [tool.coverage.run]
 source = ["logot", "tests"]


Test patch:
diff --git a/_logot_pytest.py b/_logot_pytest.py
deleted file mode 100644
index 26e8bf34..00000000
--- a/_logot_pytest.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from __future__ import annotations
-
-from collections.abc import Generator
-from typing import TYPE_CHECKING
-
-import pytest
-
-if TYPE_CHECKING:
-    # Don't import `logot` until the fixture runs.
-    # This avoids problem with pytest coverage reporting.
-    from logot import Logot
-
-
-@pytest.fixture()
-def logot() -> Generator[Logot, None, None]:
-    from logot import Logot
-
-    with Logot().capturing() as logot:
-        yield logot
diff --git a/logot/_pytest.py b/logot/_pytest.py
new file mode 100644
index 00000000..f190f8cc
--- /dev/null
+++ b/logot/_pytest.py
@@ -0,0 +1,13 @@
+from __future__ import annotations
+
+from collections.abc import Generator
+
+import pytest
+
+from logot._logot import Logot
+
+
+@pytest.fixture()
+def logot() -> Generator[Logot, None, None]:
+    with Logot().capturing() as logot:
+        yield logot