Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ae5af15e
Commit
ae5af15e
authored
Sep 01, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor: tweak docstrings and __all__ in packaging.tests.support
parent
0ac4a5d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
Lib/packaging/tests/support.py
Lib/packaging/tests/support.py
+27
-13
No files found.
Lib/packaging/tests/support.py
View file @
ae5af15e
"""Support code for packaging test cases.
*This module should not be considered public: its content and API may
change in incompatible ways.*
A few helper classes are provided: LoggingCatcher, TempdirManager and
EnvironRestorer. They are written to be used as mixins::
...
...
@@ -7,6 +10,7 @@ EnvironRestorer. They are written to be used as mixins::
from packaging.tests.support import LoggingCatcher
class SomeTestCase(LoggingCatcher, unittest.TestCase):
...
If you need to define a setUp method on your test class, you have to
call the mixin class' setUp method or it won't work (same thing for
...
...
@@ -14,17 +18,18 @@ tearDown):
def setUp(self):
super(SomeTestCase, self).setUp()
... # other setup code
...
# other setup code
Also provided is a DummyCommand class, useful to mock commands in the
tests of another command that needs them, a create_distribution function
and a skip_unless_symlink decorator.
tests of another command that needs them, for example to fake
compilation in build_ext (this requires that the mock build_ext command
be injected into the distribution object's command_obj dictionary).
Also provided is a DummyCommand class, useful to mock commands in the
tests of another command that needs them, a create_distribution function
and a skip_unless_symlink decorator.
For tests that need to compile an extension module, use the
copy_xxmodule_c and fixup_build_ext functions.
Each class or function has a docstring to explain its purpose and usage.
Existing tests should also be used as examples.
"""
import
os
...
...
@@ -39,9 +44,17 @@ from packaging.dist import Distribution
from
packaging.tests
import
unittest
from
test.support
import
requires_zlib
,
unlink
__all__
=
[
'LoggingCatcher'
,
'TempdirManager'
,
'EnvironRestorer'
,
'DummyCommand'
,
'unittest'
,
'create_distribution'
,
'skip_unless_symlink'
,
'requires_zlib'
,
'copy_xxmodule_c'
]
# define __all__ to make pydoc more useful
__all__
=
[
# TestCase mixins
'LoggingCatcher'
,
'TempdirManager'
,
'EnvironRestorer'
,
# mocks
'DummyCommand'
,
'TestDistribution'
,
# misc. functions and decorators
'fake_dec'
,
'create_distribution'
,
'copy_xxmodule_c'
,
'fixup_build_ext'
,
# imported from this module for backport purposes
'unittest'
,
'requires_zlib'
,
'skip_unless_symlink'
,
]
logger
=
logging
.
getLogger
(
'packaging'
)
...
...
@@ -233,6 +246,8 @@ class DummyCommand:
Useful for mocking one dependency command in the tests for another
command, see e.g. the dummy build command in test_build_scripts.
"""
# XXX does not work with dist.get_reinitialized_command, which typechecks
# and wants a finalized attribute
def
__init__
(
self
,
**
kwargs
):
for
kw
,
val
in
kwargs
.
items
():
...
...
@@ -308,10 +323,9 @@ def _get_xxmodule_path():
def
fixup_build_ext
(
cmd
):
"""Function needed to make build_ext tests pass.
When Python was build with --enable-shared on Unix, -L. is not good
enough to find the libpython<blah>.so. This is because regrtest runs
it under a tempdir, not in the top level where the .so lives. By the
time we've gotten here, Python's already been chdir'd to the tempdir.
When Python was built with --enable-shared on Unix, -L. is not enough to
find libpython<blah>.so, because regrtest runs in a tempdir, not in the
source directory where the .so lives.
When Python was built with in debug mode on Windows, build_ext commands
need their debug attribute set, and it is not done automatically for
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment