Repository: mwouts/jupytext (language: python)

Issue:
Python 3.13 compatibility
With python 3.13.0b2, 2 tests fail like this:
```
_____________ ERROR at setup of test_cm_config_log_only_if_changed _____________

tmp_path = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_cm_config_log_only_if_cha0')

    @pytest.fixture()
    def cwd_tmp_path(tmp_path):
        # Run the whole test from inside tmp_path
>       with tmp_path.cwd():
E       TypeError: 'PosixPath' object does not support the context manager protocol

/builddir/build/BUILD/python-jupytext-1.16.2-build/jupytext-1.16.2/tests/conftest.py:50: TypeError
```

With python 3.11 and later, this works:
```
import contextlib

@pytest.fixture()
def cwd_tmp_path(tmp_path):
    # Run the whole test from inside tmp_path
    with contextlib.chdir(tmp_path):
        yield tmp_path
```



Discussion / hints:
Thanks @jamesjer for looking into this! That's very helpful. I guess we could code two different fixtures and activate either one depending on the Python version, then?
Yes, I guess so.  That seems kind of ugly, but I don't have any better ideas.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0edbf683..935091a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,9 @@ Jupytext ChangeLog
 **Fixed**
 - The `rst2md` tests have been fixed by requiring `sphinx<8` ([#1266](https://github.com/mwouts/jupytext/issues/1266))
 
+**Added**
+- Jupytext is now tested with Python 3.13 ([#1242](https://github.com/mwouts/jupytext/issues/1242)). Thanks to [Jerry James](https://github.com/jamesjer) for the suggested fixes!
+
 
 1.16.4 (2024-07-12)
 -------------------
diff --git a/environment.yml b/environment.yml
index 576b7dcf..52f63845 100644
--- a/environment.yml
+++ b/environment.yml
@@ -3,7 +3,7 @@ channels:
   - defaults
   - conda-forge
 dependencies:
-  - python>=3.8,<3.12
+  - python>=3.8
   - jupyterlab>=4.0.0
   - nbformat>=5.1.2
   - pre-commit
diff --git a/pyproject.toml b/pyproject.toml
index 017d3fef..f62f9cd3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -29,6 +29,7 @@ classifiers = [
     "Programming Language :: Python :: 3.10",
     "Programming Language :: Python :: 3.11",
     "Programming Language :: Python :: 3.12",
+    "Programming Language :: Python :: 3.13",
 ]
 dependencies = [
     "nbformat",


Test patch:
diff --git a/.github/workflows/step_tests-pip.yml b/.github/workflows/step_tests-pip.yml
index f3d5ccd9..dc28bcd4 100644
--- a/.github/workflows/step_tests-pip.yml
+++ b/.github/workflows/step_tests-pip.yml
@@ -26,7 +26,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12"]
+        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
         experimental: [false]
         include:
           # Test pre-release versions
diff --git a/tests/conftest.py b/tests/conftest.py
index 3d76dfbf..e11227a8 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,3 +1,4 @@
+import contextlib
 import itertools
 import os.path
 import re
@@ -47,8 +48,13 @@ def cwd_tmpdir(tmpdir):
 @pytest.fixture()
 def cwd_tmp_path(tmp_path):
     # Run the whole test from inside tmp_path
-    with tmp_path.cwd():
-        yield tmp_path
+    if sys.version_info < (3, 11):
+        with tmp_path.cwd():
+            yield tmp_path
+    else:
+        # https://github.com/mwouts/jupytext/issues/1242
+        with contextlib.chdir(tmp_path):
+            yield tmp_path
 
 
 @pytest.fixture