Repository: ipums/hlink (language: python)

Issue:
Enable running tests with just the command `pytest`
Right now you need to type `pytest hlink/tests` to run hlink's tests. If you type `pytest` without any arguments, this error is printed:

```
====================================================== test session starts =======================================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0
rootdir: /hlink, configfile: pytest.ini
plugins: cov-4.0.0
collected 0 items / 1 error                                                                                                      

============================================================= ERRORS =============================================================
_________________________________________________ ERROR collecting test session __________________________________________________
Defining 'pytest_plugins' in a non-top-level conftest is no longer supported:
It affects the entire test suite instead of just below the conftest as expected.
  /hlink/hlink/tests/conftest.py
Please move it to a top level conftest file at the rootdir:
 /hlink
For more information, visit:
  https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-files
==================================================== short test summary info =====================================================
ERROR 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================== 1 error in 7.66s ========================================================
```

It would be nice to look into changing this so that the tests can be run as just 'pytest'. This may involve some changes to CI/CD as well to change the invocation of pytest there.


Discussion / hints:
Looks like we'll need to move the declaration of `pytest_plugins` into a top-level conftest.py file to fix this.

Fix patch:
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
index c802864..87ec761 100644
--- a/.github/workflows/docker-build.yml
+++ b/.github/workflows/docker-build.yml
@@ -23,7 +23,7 @@ jobs:
       run: docker run $HLINK_TAG flake8 --count .
       
     - name: Test
-      run: docker run $HLINK_TAG pytest hlink/tests
+      run: docker run $HLINK_TAG pytest
     
     - name: Build sdist and wheel
       run: docker run $HLINK_TAG python -m build
diff --git a/doc/developer.md b/doc/developer.md
index 160971c..c9d55ac 100644
--- a/doc/developer.md
+++ b/doc/developer.md
@@ -19,9 +19,9 @@ To set up a copy of this project for development,
 
 ## Running Tests
 
-To run the project's test suite, run `pytest hlink/tests` in the root project directory. Running all of the tests
+To run the project's test suite, run `pytest` in the root project directory. Running all of the tests
 can take a while, depending on your computer's hardware and setup. To run a subset of tests that test some but not
-all of the core features, try `pytest hlink/tests -m quickcheck`. These tests should run much more quickly.
+all of the core features, try `pytest -m quickcheck`. These tests should run much more quickly.
 
 ## Building the Scala Jar
 


Test patch:
diff --git a/conftest.py b/conftest.py
new file mode 100644
index 0000000..e77c8f3
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,4 @@
+pytest_plugins = (
+    "hlink.tests.plugins.datasources",
+    "hlink.tests.plugins.external_data_paths",
+)
diff --git a/hlink/tests/conftest.py b/hlink/tests/conftest.py
index 4a4f5d2..426bb83 100755
--- a/hlink/tests/conftest.py
+++ b/hlink/tests/conftest.py
@@ -23,12 +23,6 @@
 from types import SimpleNamespace
 
 
-pytest_plugins = (
-    "hlink.tests.plugins.datasources",
-    "hlink.tests.plugins.external_data_paths",
-)
-
-
 def load_table_from_csv(link_task, path, table_name):
     link_task.spark.read.csv(path, header=True, inferSchema=True).write.mode(
         "overwrite"