Repository: PolicyEngine/policyengine-core (language: python)

Issue:
Relax pytest version requirements
Per https://github.com/PolicyEngine/policyengine-uk/issues/645, pytest version requirements are causing conflicts.

[We restrict the version range](https://github.com/PolicyEngine/policyengine-core/blob/master/setup.py#L13) in a way that mirrors [openfisca-core](https://github.com/openfisca/openfisca-core/blob/master/setup.py#L19). Can we uncap the version?


Discussion / hints:
De-assigning for now because I think this is quite complex and not an immediate prioriy

Fix patch:
diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml
index 67a4aed26..03558cec6 100644
--- a/.github/workflows/push.yaml
+++ b/.github/workflows/push.yaml
@@ -82,7 +82,7 @@ jobs:
       - name: Setup Python
         uses: actions/setup-python@v4
         with:
-          python-version: 3.10
+          python-version: "3.10"
       - name: Publish a git tag
         run: ".github/publish-git-tag.sh || true"
       - name: Install package
diff --git a/changelog_entry.yaml b/changelog_entry.yaml
index e69de29bb..7047044e7 100644
--- a/changelog_entry.yaml
+++ b/changelog_entry.yaml
@@ -0,0 +1,4 @@
+- bump: patch
+  changes:
+    fixed:
+    - Fixed pytest deprecated usages since version 7, and fixed a bug that prevented new package from publishing.
\ No newline at end of file
diff --git a/setup.py b/setup.py
index eb7319250..0d660a66d 100644
--- a/setup.py
+++ b/setup.py
@@ -59,6 +59,7 @@
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
+        "Programming Language :: Python :: 3.10",
         "Topic :: Scientific/Engineering :: Information Analysis",
     ],
     description="Core microsimulation engine enabling country-specific policy models.",


Test patch:
diff --git a/policyengine_core/tools/test_runner.py b/policyengine_core/tools/test_runner.py
index 95918c3e9..4ef3024b9 100644
--- a/policyengine_core/tools/test_runner.py
+++ b/policyengine_core/tools/test_runner.py
@@ -110,19 +110,19 @@ def run_tests(tax_benefit_system, paths, options=None):
 
 
 class YamlFile(pytest.File):
-    def __init__(self, path, fspath, parent, tax_benefit_system, options):
-        super(YamlFile, self).__init__(path, parent)
+    def __init__(self, *, tax_benefit_system, options, **kwargs):
+        super(YamlFile, self).__init__(**kwargs)
         self.tax_benefit_system = tax_benefit_system
         self.options = options
 
     def collect(self):
         try:
-            tests = yaml.load(self.fspath.open(), Loader=Loader)
+            tests = yaml.load(self.path.open(), Loader=Loader)
         except (yaml.scanner.ScannerError, yaml.parser.ParserError, TypeError):
             message = os.linesep.join(
                 [
                     traceback.format_exc(),
-                    f"'{self.fspath}' is not a valid YAML file. Check the stack trace above for more details.",
+                    f"'{self.path}' is not a valid YAML file. Check the stack trace above for more details.",
                 ]
             )
             raise ValueError(message)
@@ -156,9 +156,9 @@ class YamlItem(pytest.Item):
     """
 
     def __init__(
-        self, name, parent, baseline_tax_benefit_system, test, options
+        self, *, baseline_tax_benefit_system, test, options, **kwargs
     ):
-        super(YamlItem, self).__init__(name, parent)
+        super(YamlItem, self).__init__(**kwargs)
         self.baseline_tax_benefit_system = baseline_tax_benefit_system
         self.options = options
         self.test = test
@@ -378,16 +378,15 @@ def __init__(self, tax_benefit_system, options):
         self.tax_benefit_system = tax_benefit_system
         self.options = options
 
-    def pytest_collect_file(self, parent, path):
+    def pytest_collect_file(self, parent, file_path):
         """
         Called by pytest for all plugins.
         :return: The collector for test methods.
         """
-        if path.ext in [".yaml", ".yml"]:
+        if file_path.suffix in [".yaml", ".yml"]:
             return YamlFile.from_parent(
                 parent,
-                path=path,
-                fspath=path,
+                path=file_path,
                 tax_benefit_system=self.tax_benefit_system,
                 options=self.options,
             )
diff --git a/tests/core/tools/test_runner/test_yaml_runner.py b/tests/core/tools/test_runner/test_yaml_runner.py
index a507f15d5..48ddf65dd 100644
--- a/tests/core/tools/test_runner/test_yaml_runner.py
+++ b/tests/core/tools/test_runner/test_yaml_runner.py
@@ -76,7 +76,11 @@ def __init__(self):
 class TestItem(YamlItem):
     def __init__(self, parent=None, test=None):
         super().__init__(
-            "", TestFile.from_parent(None), TaxBenefitSystem(), test, {}
+            name="",
+            parent=TestFile.from_parent(None),
+            baseline_tax_benefit_system=TaxBenefitSystem(),
+            test=test,
+            options={},
         )
 
         self.tax_benefit_system = self.baseline_tax_benefit_system