Skip to content

Commit

Permalink
test_base: fix deprecation decorator tests on 3.13
Browse files Browse the repository at this point in the history
 * __doc__ is now mangled, python/cpython#81283.
  • Loading branch information
jtniehof committed Oct 14, 2024
1 parent 033dd0a commit 5276685
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Copyright 2012 Los Alamos National Security, LLC.
"""

import inspect
import os
import shutil
import tempfile
Expand All @@ -31,15 +32,13 @@ def testfunc(x):
"""
return x + 1
self.assertEqual(
"test function\n"
"\n"
" test function\n"
"\n"
" .. deprecated:: 0.1\n"
" pithy message\n"
".. deprecated:: 0.1\n"
" pithy message\n"
"\n"
" this will test things\n"
" ",
testfunc.__doc__)
"this will test things",
inspect.getdoc(testfunc))
with spacepy_testing.assertWarns(self, 'always', r'.*pithy message$',
DeprecationWarning):
self.assertEqual(2, testfunc(1))
Expand All @@ -50,10 +49,9 @@ def testDeprecationNone(self):
def testfunc(x):
return x + 1
self.assertEqual(
"\n"
" .. deprecated:: 0.1\n"
" pithy message",
testfunc.__doc__)
".. deprecated:: 0.1\n"
" pithy message",
inspect.getdoc(testfunc))
with spacepy_testing.assertWarns(self, 'always', r'pithy message$',
DeprecationWarning):
self.assertEqual(2, testfunc(1))
Expand All @@ -70,12 +68,11 @@ def testfunc(x):
self.assertEqual(
"test function\n"
"\n"
" .. deprecated:: 0.1\n"
" pithy message\n"
".. deprecated:: 0.1\n"
" pithy message\n"
"\n"
" this will test things\n"
" ",
testfunc.__doc__)
"this will test things",
inspect.getdoc(testfunc))

def testDeprecationDifferentMessage(self):
"""Test the deprecation decorator, docstring different from message"""
Expand All @@ -89,13 +86,12 @@ def testfunc(x):
self.assertEqual(
"test function\n"
"\n"
" .. deprecated:: 0.1\n"
" foo\n"
" bar\n"
".. deprecated:: 0.1\n"
" foo\n"
" bar\n"
"\n"
" this will test things\n"
" ",
testfunc.__doc__)
"this will test things",
inspect.getdoc(testfunc))
with spacepy_testing.assertWarns(self, 'always', r'pithy message$',
DeprecationWarning):
self.assertEqual(2, testfunc(1))
Expand All @@ -111,7 +107,7 @@ def testfunc(x):
"\n"
".. deprecated:: 0.1\n"
" pithy message",
testfunc.__doc__)
inspect.getdoc(testfunc))


class SpacepyDirTests(unittest.TestCase):
Expand Down

0 comments on commit 5276685

Please sign in to comment.