Hi,
I created a patch to fix this auto test issue with Python 3.12. I am
attaching the debdiff file for you to checkout.

I have created a branch too in the salsa [0], if it looks ok, you can
MR.

[0] 
https://salsa.debian.org/python-team/packages/python-docx/-/tree/fix-for-auto-test-error-Py312?ref_type=heads

Cheers!
diff -Nru python-docx-1.1.0+dfsg/debian/changelog 
python-docx-1.1.0+dfsg/debian/changelog
--- python-docx-1.1.0+dfsg/debian/changelog     2023-11-22 06:24:08.000000000 
+0000
+++ python-docx-1.1.0+dfsg/debian/changelog     2024-01-13 20:00:00.000000000 
+0000
@@ -1,3 +1,11 @@
+python-docx (1.1.0+dfsg-2) UNRELEASED; urgency=medium
+
+  * Team upload.
+  * Patch for dh_auto_test datetime DeprecationWarning with
+    Python 3.12. (Closes: #1058441)
+
+ -- Yogeswaran Umasankar <kd8...@gmail.com>  Sat, 13 Jan 2024 20:00:00 +0000
+
 python-docx (1.1.0+dfsg-1) unstable; urgency=medium
 
   * New upstream version 1.1.0+dfsg
diff -Nru 
python-docx-1.1.0+dfsg/debian/patches/fix-DescribeCorePropertiesPart-py312.patch
 
python-docx-1.1.0+dfsg/debian/patches/fix-DescribeCorePropertiesPart-py312.patch
--- 
python-docx-1.1.0+dfsg/debian/patches/fix-DescribeCorePropertiesPart-py312.patch
    1970-01-01 00:00:00.000000000 +0000
+++ 
python-docx-1.1.0+dfsg/debian/patches/fix-DescribeCorePropertiesPart-py312.patch
    2024-01-13 20:00:00.000000000 +0000
@@ -0,0 +1,56 @@
+Description: Fixed datetime DeprecationWarning in Python 3.12.
+ Issue caused because modified_datetime returns None.
+Author: Yogeswaran Umasankar <kd8...@gmail.com>
+Last-Update: 2024-01-08
+
+--- a/src/docx/opc/parts/coreprops.py
++++ b/src/docx/opc/parts/coreprops.py
+@@ -1,6 +1,6 @@
+ """Core properties part, corresponds to ``/docProps/core.xml`` part in 
package."""
+ 
+-from datetime import datetime
++from datetime import datetime, timezone
+ 
+ from docx.opc.constants import CONTENT_TYPE as CT
+ from docx.opc.coreprops import CoreProperties
+@@ -22,7 +22,7 @@ class CorePropertiesPart(XmlPart):
+         core_properties.title = "Word Document"
+         core_properties.last_modified_by = "python-docx"
+         core_properties.revision = 1
+-        core_properties.modified = datetime.utcnow()
++        core_properties.modified = datetime.now(timezone.utc)
+         return core_properties_part
+ 
+     @property
+--- a/tests/opc/parts/test_coreprops.py
++++ b/tests/opc/parts/test_coreprops.py
+@@ -1,6 +1,6 @@
+ """Unit test suite for the docx.opc.parts.coreprops module."""
+ 
+-from datetime import datetime, timedelta
++from datetime import datetime, timedelta, timezone
+ 
+ import pytest
+ 
+@@ -25,7 +25,8 @@ class DescribeCorePropertiesPart:
+         assert core_properties.title == "Word Document"
+         assert core_properties.last_modified_by == "python-docx"
+         assert core_properties.revision == 1
+-        delta = datetime.utcnow() - core_properties.modified
++        # Handles if modified_datetime is None
++        delta = datetime.now(timezone.utc) - 
(core_properties.modified.replace(tzinfo=timezone.utc) if 
core_properties.modified else None)
+         max_expected_delta = timedelta(seconds=2)
+         assert delta < max_expected_delta
+ 
+--- a/src/docx/opc/coreprops.py
++++ b/src/docx/opc/coreprops.py
+@@ -93,7 +93,8 @@ class CoreProperties:
+ 
+     @property
+     def modified(self):
+-        return self._element.modified_datetime
++        # Handles if modified_datetime is None
++        return self._element.modified_datetime if 
self._element.modified_datetime is not None else None
+ 
+     @modified.setter
+     def modified(self, value):
diff -Nru python-docx-1.1.0+dfsg/debian/patches/series 
python-docx-1.1.0+dfsg/debian/patches/series
--- python-docx-1.1.0+dfsg/debian/patches/series        2023-11-22 
06:21:09.000000000 +0000
+++ python-docx-1.1.0+dfsg/debian/patches/series        2024-01-13 
20:00:00.000000000 +0000
@@ -1 +1,2 @@
+fix-DescribeCorePropertiesPart-py312.patch
 adjust-to-image-removals.patch

Reply via email to