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

Commit4a4d880

Browse files
committed
Improve test suite import grouping/sorting, __all__ placement
There is only one __all__ in the test suite, so this is mostly thechange to imports, grouping and sorting them in a fully consistentstyle that is the same as the import style in the code under test.
1 parentf705fd6 commit4a4d880

27 files changed

+99
-95
lines changed

‎test/lib/helper.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
__all__= [
7+
"fixture_path",
8+
"fixture",
9+
"StringProcessAdapter",
10+
"with_rw_directory",
11+
"with_rw_repo",
12+
"with_rw_and_rw_remote_repo",
13+
"TestBase",
14+
"VirtualEnvironment",
15+
"TestCase",
16+
"SkipTest",
17+
"skipIf",
18+
"GIT_REPO",
19+
"GIT_DAEMON_PORT",
20+
]
21+
622
importcontextlib
723
fromfunctoolsimportwraps
824
importgc
@@ -31,22 +47,6 @@
3147
GIT_REPO=os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE",ospd(ospd(ospd(__file__))))
3248
GIT_DAEMON_PORT=os.environ.get("GIT_PYTHON_TEST_GIT_DAEMON_PORT","19418")
3349

34-
__all__= (
35-
"fixture_path",
36-
"fixture",
37-
"StringProcessAdapter",
38-
"with_rw_directory",
39-
"with_rw_repo",
40-
"with_rw_and_rw_remote_repo",
41-
"TestBase",
42-
"VirtualEnvironment",
43-
"TestCase",
44-
"SkipTest",
45-
"skipIf",
46-
"GIT_REPO",
47-
"GIT_DAEMON_PORT",
48-
)
49-
5050
_logger=logging.getLogger(__name__)
5151

5252
# { Routines

‎test/performance/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This module is part of GitPython and is released under the
2+
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

‎test/performance/lib.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55

66
importlogging
77
importos
8+
importos.pathasosp
89
importtempfile
910

1011
fromgitimportRepo
1112
fromgit.dbimportGitCmdObjectDB,GitDB
12-
fromtest.libimportTestBase
1313
fromgit.utilimportrmtree
14-
importos.pathasosp
14+
15+
fromtest.libimportTestBase
1516

1617
# { Invariants
1718

‎test/performance/test_commit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
fromtimeimporttime
1111
importsys
1212

13-
from .libimportTestBigRepoRW
14-
fromgitimportCommit
1513
fromgitdbimportIStream
14+
15+
fromgitimportCommit
16+
17+
fromtest.performance.libimportTestBigRepoRW
1618
fromtest.test_commitimportTestCommitSerialization
1719

1820

‎test/performance/test_odb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
importsys
77
fromtimeimporttime
88

9-
from .libimportTestBigRepoR
9+
fromtest.performance.libimportTestBigRepoR
1010

1111

1212
classTestObjDBPerformance(TestBigRepoR):

‎test/performance/test_streams.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
importgc
77
importos
8+
importos.pathasosp
89
importsubprocess
910
importsys
1011
fromtimeimporttime
1112

12-
fromtest.libimportwith_rw_repo
13-
fromgit.utilimportbin_to_hex
1413
fromgitdbimportLooseObjectDB,IStream
1514
fromgitdb.test.libimportmake_memory_file
1615

17-
importos.pathasosp
16+
fromgit.utilimportbin_to_hex
1817

19-
from .libimportTestBigRepoR
18+
fromtest.libimportwith_rw_repo
19+
fromtest.performance.libimportTestBigRepoR
2020

2121

2222
classTestObjDBPerformance(TestBigRepoR):

‎test/test_actor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6-
fromtest.libimportTestBase
76
fromgitimportActor
87

8+
fromtest.libimportTestBase
9+
910

1011
classTestActor(TestBase):
1112
deftest_from_string_should_separate_name_and_email(self):

‎test/test_base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
importgc
77
importos
8+
importos.pathasosp
89
importsys
910
importtempfile
1011
fromunittestimportskipIf
1112

1213
fromgitimportRepo
13-
fromgit.objectsimportBlob,Tree,Commit,TagObject
14+
fromgit.objectsimportBlob,Commit,TagObject,Tree
15+
importgit.objects.baseasbase
1416
fromgit.objects.utilimportget_object_type_by_name
15-
fromtest.libimportTestBaseas_TestBase,with_rw_repo,with_rw_and_rw_remote_repo
16-
fromgit.utilimporthex_to_bin,HIDE_WINDOWS_FREEZE_ERRORS
17+
fromgit.utilimportHIDE_WINDOWS_FREEZE_ERRORS,hex_to_bin
1718

18-
importgit.objects.baseasbase
19-
importos.pathasosp
19+
fromtest.libimportTestBaseas_TestBase,with_rw_and_rw_remote_repo,with_rw_repo
2020

2121

2222
classTestBase(_TestBase):

‎test/test_blob.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6-
fromtest.libimportTestBase
76
fromgitimportBlob
87

8+
fromtest.libimportTestBase
9+
910

1011
classTestBlob(TestBase):
1112
deftest_mime_type_should_return_mime_type_for_known_types(self):

‎test/test_clone.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
importgit
88

9-
from .libimport (
10-
TestBase,
11-
with_rw_directory,
12-
)
9+
fromtest.libimportTestBase,with_rw_directory
1310

1411

1512
classTestClone(TestBase):

‎test/test_commit.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@
66
importcopy
77
fromdatetimeimportdatetime
88
fromioimportBytesIO
9+
importos.pathasosp
910
importre
1011
importsys
1112
importtime
1213
fromunittest.mockimportMock
1314

14-
fromgitimport (
15-
Commit,
16-
Actor,
17-
)
18-
fromgitimportRepo
15+
fromgitdbimportIStream
16+
17+
fromgitimportActor,Commit,Repo
1918
fromgit.objects.utilimporttzoffset,utc
2019
fromgit.repo.funimporttouch
21-
fromtest.libimportTestBase,with_rw_repo,fixture_path,StringProcessAdapter
22-
fromtest.libimportwith_rw_directory
23-
fromgitdbimportIStream
2420

25-
importos.pathasosp
21+
fromtest.libimport (
22+
StringProcessAdapter,
23+
TestBase,
24+
fixture_path,
25+
with_rw_directory,
26+
with_rw_repo,
27+
)
2628

2729

2830
classTestCommitSerialization(TestBase):

‎test/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
fromgitimportGitConfigParser
1616
fromgit.configimport_OMD,cp
1717
fromgit.utilimportrmfile
18-
fromtest.libimportSkipTest,TestCase,fixture_path,with_rw_directory
1918

19+
fromtest.libimportSkipTest,TestCase,fixture_path,with_rw_directory
2020

2121
_tc_lock_fpaths=osp.join(osp.dirname(__file__),"fixtures/*.lock")
2222

‎test/test_db.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
importos.pathasosp
7+
68
fromgit.dbimportGitCmdObjectDB
79
fromgit.excimportBadObject
8-
fromtest.libimportTestBase
910
fromgit.utilimportbin_to_hex
1011

11-
importos.pathasosp
12+
fromtest.libimportTestBase
1213

1314

1415
classTestDB(TestBase):

‎test/test_diff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
fromgitimportNULL_TREE,Diff,DiffIndex,Diffable,GitCommandError,Repo,Submodule
1616
fromgit.cmdimportGit
17+
1718
fromtest.libimportStringProcessAdapter,TestBase,fixture,with_rw_directory
1819

1920

‎test/test_docs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55

66
importgc
77
importos
8+
importos.path
89
importsys
910

1011
importpytest
1112

1213
fromtest.libimportTestBase
1314
fromtest.lib.helperimportwith_rw_directory
1415

15-
importos.path
16-
1716

1817
classTutorials(TestBase):
1918
deftearDown(self):

‎test/test_exc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
fromitertoolsimportproduct
67
importre
78

89
importddt
10+
911
fromgit.excimport (
1012
InvalidGitRepositoryError,
1113
WorkTreeRepositoryUnsupported,
@@ -20,9 +22,8 @@
2022
RepositoryDirtyError,
2123
)
2224
fromgit.utilimportremove_password_if_present
23-
fromtest.libimportTestBase
2425

25-
importitertoolsasitt
26+
fromtest.libimportTestBase
2627

2728

2829
_cmd_argvs= (
@@ -79,7 +80,7 @@ def test_ExceptionsHaveBaseClass(self):
7980
forex_classinexception_classes:
8081
self.assertTrue(issubclass(ex_class,GitError))
8182

82-
@ddt.data(*list(itt.product(_cmd_argvs,_causes_n_substrings,_streams_n_substrings)))
83+
@ddt.data(*list(product(_cmd_argvs,_causes_n_substrings,_streams_n_substrings)))
8384
deftest_CommandError_unicode(self,case):
8485
argv, (cause,subs),stream=case
8586
cls=CommandError

‎test/test_fun.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

44
fromioimportBytesIO
5-
fromstatimportS_IFDIR,S_IFREG,S_IFLNK,S_IXUSR
5+
fromstatimportS_IFDIR,S_IFLNK,S_IFREG,S_IXUSR
66
fromosimportstat
77
importos.pathasosp
88

9+
fromgitdb.baseimportIStream
10+
fromgitdb.typimportstr_tree_type
11+
912
fromgitimportGit
1013
fromgit.indeximportIndexFile
11-
fromgit.index.funimport (
12-
aggressive_tree_merge,
13-
stat_mode_to_index_mode,
14-
)
14+
fromgit.index.funimportaggressive_tree_merge,stat_mode_to_index_mode
1515
fromgit.objects.funimport (
1616
traverse_tree_recursive,
1717
traverse_trees_recursive,
18-
tree_to_stream,
1918
tree_entries_from_data,
19+
tree_to_stream,
2020
)
2121
fromgit.repo.funimportfind_worktree_git_dir
22-
fromtest.libimportTestBase,with_rw_repo,with_rw_directory
2322
fromgit.utilimportbin_to_hex,cygpath,join_path_native
24-
fromgitdb.baseimportIStream
25-
fromgitdb.typimportstr_tree_type
23+
24+
fromtest.libimportTestBase,with_rw_directory,with_rw_repo
2625

2726

2827
classTestFun(TestBase):

‎test/test_git.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
importddt
2727

28-
fromgitimportGit,refresh,GitCommandError,GitCommandNotFound,Repo,cmd
28+
fromgitimportGit,GitCommandError,GitCommandNotFound,Repo,cmd,refresh
2929
fromgit.utilimportcwd,finalize_process
30+
3031
fromtest.libimportTestBase,fixture_path,with_rw_directory
3132

3233

‎test/test_index.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,12 @@
1717
importsys
1818
importtempfile
1919

20+
fromgitdb.baseimportIStream
21+
2022
importddt
2123
importpytest
2224

23-
fromgitimport (
24-
BlobFilter,
25-
Diff,
26-
Git,
27-
IndexFile,
28-
Object,
29-
Repo,
30-
Tree,
31-
)
25+
fromgitimportBlobFilter,Diff,Git,IndexFile,Object,Repo,Tree
3226
fromgit.excimport (
3327
CheckoutError,
3428
GitCommandError,
@@ -41,7 +35,7 @@
4135
fromgit.index.utilimportTemporaryFileSwap
4236
fromgit.objectsimportBlob
4337
fromgit.utilimportActor,cwd,hex_to_bin,rmtree
44-
fromgitdb.baseimportIStream
38+
4539
fromtest.libimport (
4640
TestBase,
4741
VirtualEnvironment,

‎test/test_reflog.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
importtempfile
66

77
fromgit.objectsimportIndexObject
8-
fromgit.refsimportRefLogEntry,RefLog
8+
fromgit.refsimportRefLog,RefLogEntry
9+
fromgit.utilimportActor,hex_to_bin,rmtree
10+
911
fromtest.libimportTestBase,fixture_path
10-
fromgit.utilimportActor,rmtree,hex_to_bin
1112

1213

1314
classTestRefLog(TestBase):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp