Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae5af15

Browse files
committed
Minor: tweak docstrings and __all__ in packaging.tests.support
1 parent 0ac4a5d commit ae5af15

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

Lib/packaging/tests/support.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
"""Support code for packaging test cases.
22
3+
*This module should not be considered public: its content and API may
4+
change in incompatible ways.*
5+
36
A few helper classes are provided: LoggingCatcher, TempdirManager and
47
EnvironRestorer. They are written to be used as mixins::
58
69
from packaging.tests import unittest
710
from packaging.tests.support import LoggingCatcher
811
912
class SomeTestCase(LoggingCatcher, unittest.TestCase):
13+
...
1014
1115
If you need to define a setUp method on your test class, you have to
1216
call the mixin class' setUp method or it won't work (same thing for
1317
tearDown):
1418
1519
def setUp(self):
1620
super(SomeTestCase, self).setUp()
17-
... # other setup code
21+
... # other setup code
1822
1923
Also provided is a DummyCommand class, useful to mock commands in the
20-
tests of another command that needs them, a create_distribution function
21-
and a skip_unless_symlink decorator.
24+
tests of another command that needs them, for example to fake
25+
compilation in build_ext (this requires that the mock build_ext command
26+
be injected into the distribution object's command_obj dictionary).
2227
23-
Also provided is a DummyCommand class, useful to mock commands in the
24-
tests of another command that needs them, a create_distribution function
25-
and a skip_unless_symlink decorator.
28+
For tests that need to compile an extension module, use the
29+
copy_xxmodule_c and fixup_build_ext functions.
2630
2731
Each class or function has a docstring to explain its purpose and usage.
32+
Existing tests should also be used as examples.
2833
"""
2934

3035
import os
@@ -39,9 +44,17 @@ def setUp(self):
3944
from packaging.tests import unittest
4045
from test.support import requires_zlib, unlink
4146

42-
__all__ = ['LoggingCatcher', 'TempdirManager', 'EnvironRestorer',
43-
'DummyCommand', 'unittest', 'create_distribution',
44-
'skip_unless_symlink', 'requires_zlib', 'copy_xxmodule_c']
47+
# define __all__ to make pydoc more useful
48+
__all__ = [
49+
# TestCase mixins
50+
'LoggingCatcher', 'TempdirManager', 'EnvironRestorer',
51+
# mocks
52+
'DummyCommand', 'TestDistribution',
53+
# misc. functions and decorators
54+
'fake_dec', 'create_distribution', 'copy_xxmodule_c', 'fixup_build_ext',
55+
# imported from this module for backport purposes
56+
'unittest', 'requires_zlib', 'skip_unless_symlink',
57+
]
4558

4659

4760
logger = logging.getLogger('packaging')
@@ -233,6 +246,8 @@ class DummyCommand:
233246
Useful for mocking one dependency command in the tests for another
234247
command, see e.g. the dummy build command in test_build_scripts.
235248
"""
249+
# XXX does not work with dist.get_reinitialized_command, which typechecks
250+
# and wants a finalized attribute
236251

237252
def __init__(self, **kwargs):
238253
for kw, val in kwargs.items():
@@ -308,10 +323,9 @@ def _get_xxmodule_path():
308323
def fixup_build_ext(cmd):
309324
"""Function needed to make build_ext tests pass.
310325
311-
When Python was build with --enable-shared on Unix, -L. is not good
312-
enough to find the libpython<blah>.so. This is because regrtest runs
313-
it under a tempdir, not in the top level where the .so lives. By the
314-
time we've gotten here, Python's already been chdir'd to the tempdir.
326+
When Python was built with --enable-shared on Unix, -L. is not enough to
327+
find libpython<blah>.so, because regrtest runs in a tempdir, not in the
328+
source directory where the .so lives.
315329
316330
When Python was built with in debug mode on Windows, build_ext commands
317331
need their debug attribute set, and it is not done automatically for

0 commit comments

Comments
 (0)