Skip to content

Commit

Permalink
Merge pull request #2374 from bendk/push-xowtowuyoqkw
Browse files Browse the repository at this point in the history
Fix docstring tests for Python 3.13
  • Loading branch information
bendk authored Dec 31, 2024
2 parents f969306 + f2d1945 commit 2baab84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import sys

# Test namespace
import uniffi_docstring_proc_macro
assert uniffi_docstring_proc_macro.__doc__
Expand All @@ -10,7 +12,12 @@

# Test function
assert test.__doc__.strip() == "<docstring-function>"
assert test_multiline.__doc__.strip() == "<docstring-multiline-function>\n <second-line>"
if sys.version_info >= (3, 13):
# 3.13 strips leading docstring whitespace
assert test_multiline.__doc__.strip() == "<docstring-multiline-function>\n<second-line>"
else:
# Previous versions don't
assert test_multiline.__doc__.strip() == "<docstring-multiline-function>\n <second-line>"
assert test_without_docstring.__doc__ is None

# Test enums
Expand Down
9 changes: 8 additions & 1 deletion fixtures/docstring/tests/bindings/test_docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import sys

# Test namespace
import uniffi_docstring
assert uniffi_docstring.__doc__
Expand All @@ -10,7 +12,12 @@

# Test function
assert test.__doc__.strip() == "<docstring-function>"
assert test_multiline.__doc__.strip() == "<docstring-multiline-function>\n <second-line>"
if sys.version_info >= (3, 13):
# 3.13 strips leading docstring whitespace
assert test_multiline.__doc__.strip() == "<docstring-multiline-function>\n<second-line>"
else:
# Previous versions don't
assert test_multiline.__doc__.strip() == "<docstring-multiline-function>\n <second-line>"
assert test_without_docstring.__doc__ is None

# Test enums
Expand Down

0 comments on commit 2baab84

Please sign in to comment.