Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbffc537

Browse files
committed
Revise docstrings/comments in test helpers
1 parentfaa19ac commitbffc537

File tree

3 files changed

+47
-48
lines changed

3 files changed

+47
-48
lines changed

‎test/fixtures/env_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Steps 3 and 4 for test_it_avoids_upcasing_unrelated_environment_variable_names.
1+
"""Steps 3 and 4 for test_it_avoids_upcasing_unrelated_environment_variable_names."""
22

33
importsubprocess
44
importsys

‎test/lib/helper.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: https://opensource.org/license/bsd-3-clause/
6+
67
importcontextlib
78
fromfunctoolsimportwraps
89
importgc
@@ -65,9 +66,10 @@ def fixture(name):
6566

6667

6768
classStringProcessAdapter(object):
69+
"""Allows strings to be used as process objects returned by subprocess.Popen.
6870
69-
"""Allows to use strings as Process object as returned by SubProcess.Popen.
70-
Its tailored to work with the test system only"""
71+
This is tailored to work with the test system only.
72+
"""
7173

7274
def__init__(self,input_string):
7375
self.stdout=io.BytesIO(input_string)
@@ -86,7 +88,7 @@ def wait(self):
8688

8789
defwith_rw_directory(func):
8890
"""Create a temporary directory which can be written to, remove it if the
89-
test succeeds, but leave it otherwise to aid additional debugging"""
91+
test succeeds, but leave it otherwise to aid additional debugging."""
9092

9193
@wraps(func)
9294
defwrapper(self):
@@ -106,7 +108,7 @@ def wrapper(self):
106108
raise
107109
finally:
108110
# Need to collect here to be sure all handles have been closed. It appears
109-
# awindows-only issue. In fact things should be deleted, as well as
111+
# aWindows-only issue. In fact things should be deleted, as well as
110112
# memory maps closed, once objects go out of scope. For some reason
111113
# though this is not the case here unless we collect explicitly.
112114
gc.collect()
@@ -117,8 +119,7 @@ def wrapper(self):
117119

118120

119121
defwith_rw_repo(working_tree_ref,bare=False):
120-
"""
121-
Same as with_bare_repo, but clones the rorepo as non-bare repository, checking
122+
"""Same as with_bare_repo, but clones the rorepo as non-bare repository, checking
122123
out the working tree at the given working_tree_ref.
123124
124125
This repository type is more costly due to the working copy checkout.
@@ -199,7 +200,7 @@ def git_daemon_launched(base_path, ip, port):
199200
base_path=base_path,
200201
as_process=True,
201202
)
202-
#yes, I know... fortunately, this is always going to work if sleep time is just large enough
203+
#Yes, I know... fortunately, this is always going to work if sleep time is just large enough.
203204
time.sleep(0.5* (1+is_win))
204205
exceptExceptionasex:
205206
msg=textwrap.dedent(
@@ -225,33 +226,36 @@ def git_daemon_launched(base_path, ip, port):
225226
log.debug("Killing git-daemon...")
226227
gd.proc.kill()
227228
exceptExceptionasex:
228-
## Either it has died (and we're here), or it won't die, again here...
229+
# Either it has died (and we're here), or it won't die, again here...
229230
log.debug("Hidden error while Killing git-daemon: %s",ex,exc_info=1)
230231

231232

232233
defwith_rw_and_rw_remote_repo(working_tree_ref):
233-
"""
234-
Same as with_rw_repo, but also provides a writable remote repository from which the
235-
rw_repo has been forked as well as a handle for a git-daemon that may be started to
236-
run the remote_repo.
237-
The remote repository was cloned as bare repository from the ro repo, whereas
238-
the rw repo has a working tree and was cloned from the remote repository.
234+
"""Same as with_rw_repo, but also provides a writable remote repository from which
235+
the rw_repo has been forked as well as a handle for a git-daemon that may be started
236+
to run the remote_repo.
239237
240-
remote_repo has two remotes: origin and daemon_origin. One uses a local url,
241-
the other uses a server url. The daemon setup must be done on system level
242-
and should be an inetd service that serves tempdir.gettempdir() and all
243-
directories in it.
238+
The remote repository was cloned as bare repository from the ro repo, whereas the rw
239+
repo has a working tree and was cloned from the remote repository.
240+
241+
remote_repo has two remotes: origin and daemon_origin. One uses a local url, the
242+
other uses a server url. The daemon setup must be done on system level and should be
243+
an inetd service that serves tempdir.gettempdir() and all directories in it.
244244
245245
The following sketch demonstrates this::
246-
rorepo ---<bare clone>---> rw_remote_repo ---<clone>---> rw_repo
246+
247+
rorepo ---<bare clone>---> rw_remote_repo ---<clone>---> rw_repo
247248
248249
The test case needs to support the following signature::
250+
249251
def case(self, rw_repo, rw_daemon_repo)
250252
251253
This setup allows you to test push and pull scenarios and hooks nicely.
252254
253-
See working dir info in with_rw_repo
254-
:note: We attempt to launch our own invocation of git-daemon, which will be shutdown at the end of the test.
255+
See working dir info in :func:`with_rw_repo`.
256+
257+
:note: We attempt to launch our own invocation of git-daemon, which will be shut
258+
down at the end of the test.
255259
"""
256260
fromgitimportGit,Remote# To avoid circular deps.
257261

@@ -264,16 +268,16 @@ def remote_repo_creator(self):
264268
rw_repo_dir=tempfile.mktemp(prefix="daemon_cloned_repo-%s-"%func.__name__)
265269

266270
rw_daemon_repo=self.rorepo.clone(rw_daemon_repo_dir,shared=True,bare=True)
267-
#recursive alternates info?
271+
#Recursive alternates info?
268272
rw_repo=rw_daemon_repo.clone(rw_repo_dir,shared=True,bare=False,n=True)
269273
try:
270274
rw_repo.head.commit=working_tree_ref
271275
rw_repo.head.reference.checkout()
272276

273-
#prepare for git-daemon
277+
#Prepare for git-daemon.
274278
rw_daemon_repo.daemon_export=True
275279

276-
#this thing is just annoying!
280+
#This thing is just annoying!
277281
withrw_daemon_repo.config_writer()ascrw:
278282
section="daemon"
279283
try:
@@ -340,9 +344,7 @@ def remote_repo_creator(self):
340344

341345

342346
classTestBase(TestCase):
343-
344-
"""
345-
Base Class providing default functionality to all tests such as:
347+
"""Base class providing default functionality to all tests such as:
346348
347349
- Utility functions provided by the TestCase base of the unittest method such as::
348350
self.fail("todo")
@@ -355,20 +357,20 @@ class TestBase(TestCase):
355357
356358
The rorepo is in fact your current project's git repo. If you refer to specific
357359
shas for your objects, be sure you choose some that are part of the immutable portion
358-
of the project history ( to assuretests don't fail for others).
360+
of the project history (so thattests don't fail for others).
359361
"""
360362

361363
def_small_repo_url(self):
362-
""":return" a path to a small, clonable repository"""
364+
""":return: A path to a small, clonable repository"""
363365
fromgit.cmdimportGit
364366

365367
returnGit.polish_url(osp.join(self.rorepo.working_tree_dir,"git/ext/gitdb/gitdb/ext/smmap"))
366368

367369
@classmethod
368370
defsetUpClass(cls):
369-
"""
370-
Dynamically add a read-only repository to our actual type. This way
371-
each test type has its own repository
371+
"""Dynamically add a read-only repository to our actual type.
372+
373+
This way,each test type has its own repository.
372374
"""
373375
fromgitimportRepo
374376

@@ -383,7 +385,9 @@ def tearDownClass(cls):
383385
def_make_file(self,rela_path,data,repo=None):
384386
"""
385387
Create a file at the given path relative to our repository, filled
386-
with the given data. Returns absolute path to created file.
388+
with the given data.
389+
390+
:return: An absolute path to the created file.
387391
"""
388392
repo=repoorself.rorepo
389393
abs_path=osp.join(repo.working_tree_dir,rela_path)

‎test/performance/lib.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Contains library functions"""
1+
"""Support library for tests."""
2+
23
importlogging
34
importos
45
importtempfile
@@ -20,22 +21,16 @@
2021

2122

2223
classTestBigRepoR(TestBase):
23-
2424
"""TestCase providing access to readonly 'big' repositories using the following
2525
member variables:
2626
27-
* gitrorepo
28-
29-
* Read-Only git repository - actually the repo of git itself
30-
31-
* puregitrorepo
27+
* gitrorepo:
28+
Read-Only git repository - actually (by default) the repo of GitPython itself.
3229
33-
* As gitrepo, but uses pure python implementation
30+
* puregitrorepo:
31+
Like gitrorepo, but uses a pure Python implementation for its object database.
3432
"""
3533

36-
# { Invariants
37-
# } END invariants
38-
3934
defsetUp(self):
4035
try:
4136
super(TestBigRepoR,self).setUp()
@@ -62,10 +57,10 @@ def tearDown(self):
6257

6358

6459
classTestBigRepoRW(TestBigRepoR):
60+
"""Like :class:`TestBigRepoR`, but provides a big repository that we can write to.
6561
66-
"""As above, but provides a big repository that we can write to.
67-
68-
Provides ``self.gitrwrepo`` and ``self.puregitrwrepo``"""
62+
Provides ``self.gitrwrepo`` and ``self.puregitrwrepo``.
63+
"""
6964

7065
defsetUp(self):
7166
self.gitrwrepo=None

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp