Repository: miketheman/pytest-socket (language: python)

Issue:
coverage reporting shows missing code, despite being run
Using `pytest-cov` to test a pytest **plugin** is a less-familiar pattern out there to follow.

The output of running the code with coverage reporting shows 67% coverage - awesome!

Adding the `--cov-report=term-missing` flag to pytest shows a large amount of code that is missing coverage, despite it actually being tested. Example:

```
---------- coverage: platform darwin, python 3.9.0-final-0 -----------
Name               Stmts   Miss  Cover   Missing
------------------------------------------------
pytest_socket.py      89     29    67%   2-12, 16-17, 25, 47-48, 65-66, 74-75, 83, 92-94, 104, 110, 116, 127, 131, 135-138, 143-146, 163
------------------------------------------------
TOTAL                 89     29    67%
```


Discussion / hints:
Looks like the pytest-cov plugin doesn't work too well with **pytest plugins**. An approach shown in https://stackoverflow.com/a/62224494/244037 is to wrap the overall execution with the `coverage run` CLI instead.

Fix patch:
diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml
index f21f83e..63b7d3f 100644
--- a/.github/workflows/python.yml
+++ b/.github/workflows/python.yml
@@ -34,4 +34,4 @@ jobs:
     - name: Prepare project for development
       run: poetry install
     - name: Test with pytest
-      run: poetry run pytest
+      run: poetry run coverage run -m pytest ; coverage report --show-missing
diff --git a/Makefile b/Makefile
index 00b0f94..07f03b6 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ endif
 	@touch $(INSTALL_STAMP)
 
 test: $(INSTALL_STAMP)
-	@poetry run pytest $(PYTEST_FLAGS)
+	@poetry run coverage run -m pytest $(PYTEST_FLAGS) ; coverage report --show-missing
 
 dist: clean $(INSTALL_STAMP)
 	@poetry build
diff --git a/pyproject.toml b/pyproject.toml
index a7500af..3f2bcd4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,8 +8,8 @@ readme = "README.md"
 homepage = "https://pypi.org/project/pytest-socket/"
 repository = "https://github.com/miketheman/pytest-socket"
 include = [
-    "LICENSE",
-    "README.md",
+    { path = "LICENSE" },
+    { path = "README.md" },
     { path = "tests", format = "sdist" },
     { path = "pytest.ini", format = "sdist" },
     { path = ".coveragerc", format = "sdist" },
@@ -35,8 +35,8 @@ python = "^3.7"
 pytest = ">=3.6.3"
 
 [tool.poetry.dev-dependencies]
+coverage = "^6.2"
 pytest = "^6.0"
-pytest-cov = "^2.8.1"
 pytest-httpbin = "^1.0"
 pytest-randomly = "^3.5.0"
 asynctest = "^0.13.0"


Test patch:
diff --git a/pytest.ini b/pytest.ini
deleted file mode 100644
index 77135b7..0000000
--- a/pytest.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[pytest]
-addopts =
-    --cov
-    --cov-report=term