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

Commit15c736d

Browse files
committed
Reformat tests with black
This actually runs black on the whole project, but the only changesare in test/ (as expected).
1 parent288cf03 commit15c736d

File tree

7 files changed

+75
-61
lines changed

7 files changed

+75
-61
lines changed

‎test/performance/test_streams.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
classTestObjDBPerformance(TestBigRepoR):
18-
1918
large_data_size_bytes=1000*1000*10# some MiB should do it
2019
moderate_data_size_bytes=1000*1000*1# just 1 MiB
2120

‎test/test_commit.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def assert_commit_serialization(self, rwrepo, commit_id, print_performance_info=
9393

9494
classTestCommit(TestCommitSerialization):
9595
deftest_bake(self):
96-
9796
commit=self.rorepo.commit("2454ae89983a4496a445ce347d7a41c0bb0ea7ae")
9897
# commits have no dict
9998
self.assertRaises(AttributeError,setattr,commit,"someattr",1)
@@ -170,15 +169,15 @@ def test_renames(self):
170169

171170
defcheck_entries(path,changes):
172171
expected= {
173-
".github/workflows/Future.yml": {
174-
'insertions':57,
175-
'deletions':0,
176-
'lines':57,
172+
".github/workflows/Future.yml": {
173+
"insertions":57,
174+
"deletions":0,
175+
"lines":57,
177176
},
178-
".github/workflows/test_pytest.yml": {
179-
'insertions':0,
180-
'deletions':55,
181-
'lines':55,
177+
".github/workflows/test_pytest.yml": {
178+
"insertions":0,
179+
"deletions":55,
180+
"lines":55,
182181
},
183182
}
184183
assertpathinexpected

‎test/test_diff.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def test_rename_override(self, rw_dir):
419419
# create and commit file_a.txt
420420
repo=Repo.init(rw_dir)
421421
file_a=osp.join(rw_dir,"file_a.txt")
422-
withopen(file_a,"w",encoding='utf-8')asoutfile:
422+
withopen(file_a,"w",encoding="utf-8")asoutfile:
423423
outfile.write("hello world\n")
424424
repo.git.add(Git.polish_url(file_a))
425425
repo.git.commit(message="Added file_a.txt")
@@ -429,21 +429,21 @@ def test_rename_override(self, rw_dir):
429429

430430
# create and commit file_b.txt with similarity index of 52
431431
file_b=osp.join(rw_dir,"file_b.txt")
432-
withopen(file_b,"w",encoding='utf-8')asoutfile:
432+
withopen(file_b,"w",encoding="utf-8")asoutfile:
433433
outfile.write("hello world\nhello world")
434434
repo.git.add(Git.polish_url(file_b))
435435
repo.git.commit(message="Removed file_a.txt. Added file_b.txt")
436436

437-
commit_a=repo.commit('HEAD')
438-
commit_b=repo.commit('HEAD~1')
437+
commit_a=repo.commit("HEAD")
438+
commit_b=repo.commit("HEAD~1")
439439

440440
# check default diff command with renamed files enabled
441441
diffs=commit_b.diff(commit_a)
442442
self.assertEqual(1,len(diffs))
443443
diff=diffs[0]
444444
self.assertEqual(True,diff.renamed_file)
445-
self.assertEqual('file_a.txt',diff.rename_from)
446-
self.assertEqual('file_b.txt',diff.rename_to)
445+
self.assertEqual("file_a.txt",diff.rename_from)
446+
self.assertEqual("file_b.txt",diff.rename_to)
447447

448448
# check diff with rename files disabled
449449
diffs=commit_b.diff(commit_a,no_renames=True)
@@ -452,31 +452,31 @@ def test_rename_override(self, rw_dir):
452452
# check fileA.txt deleted
453453
diff=diffs[0]
454454
self.assertEqual(True,diff.deleted_file)
455-
self.assertEqual('file_a.txt',diff.a_path)
455+
self.assertEqual("file_a.txt",diff.a_path)
456456

457457
# check fileB.txt added
458458
diff=diffs[1]
459459
self.assertEqual(True,diff.new_file)
460-
self.assertEqual('file_b.txt',diff.a_path)
460+
self.assertEqual("file_b.txt",diff.a_path)
461461

462462
# check diff with high similarity index
463-
diffs=commit_b.diff(commit_a,split_single_char_options=False,M='75%')
463+
diffs=commit_b.diff(commit_a,split_single_char_options=False,M="75%")
464464
self.assertEqual(2,len(diffs))
465465

466466
# check fileA.txt deleted
467467
diff=diffs[0]
468468
self.assertEqual(True,diff.deleted_file)
469-
self.assertEqual('file_a.txt',diff.a_path)
469+
self.assertEqual("file_a.txt",diff.a_path)
470470

471471
# check fileB.txt added
472472
diff=diffs[1]
473473
self.assertEqual(True,diff.new_file)
474-
self.assertEqual('file_b.txt',diff.a_path)
474+
self.assertEqual("file_b.txt",diff.a_path)
475475

476476
# check diff with low similarity index
477-
diffs=commit_b.diff(commit_a,split_single_char_options=False,M='40%')
477+
diffs=commit_b.diff(commit_a,split_single_char_options=False,M="40%")
478478
self.assertEqual(1,len(diffs))
479479
diff=diffs[0]
480480
self.assertEqual(True,diff.renamed_file)
481-
self.assertEqual('file_a.txt',diff.rename_from)
482-
self.assertEqual('file_b.txt',diff.rename_to)
481+
self.assertEqual("file_a.txt",diff.rename_from)
482+
self.assertEqual("file_b.txt",diff.rename_to)

‎test/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def test_commit_msg_hook_fail(self, rw_repo):
946946
else:
947947
raiseAssertionError("Should have caught a HookExecutionError")
948948

949-
@with_rw_repo('HEAD')
949+
@with_rw_repo("HEAD")
950950
deftest_index_add_pathlike(self,rw_repo):
951951
git_dir=Path(rw_repo.git_dir)
952952

‎test/test_quick_doc.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,23 @@ def tearDown(self):
1313

1414
@with_rw_directory
1515
deftest_init_repo_object(self,path_to_dir):
16-
1716
# [1-test_init_repo_object]
1817
# $ git init <path/to/dir>
1918

2019
fromgitimportRepo
2120

2221
repo=Repo.init(path_to_dir)
23-
# ![1-test_init_repo_object]
22+
# ![1-test_init_repo_object]
2423

2524
# [2-test_init_repo_object]
2625
repo=Repo(path_to_dir)
2726
# ![2-test_init_repo_object]
2827

2928
@with_rw_directory
3029
deftest_cloned_repo_object(self,local_dir):
31-
3230
fromgitimportRepo
3331
importgit
32+
3433
# code to clone from url
3534
# [1-test_cloned_repo_object]
3635
# $ git clone <url> <local_dir>
@@ -44,9 +43,9 @@ def test_cloned_repo_object(self, local_dir):
4443
# [2-test_cloned_repo_object]
4544
# We must make a change to a file so that we can add the update to git
4645

47-
update_file='dir1/file2.txt'# we'll use local_dir/dir1/file2.txt
48-
withopen(f"{local_dir}/{update_file}",'a')asf:
49-
f.write('\nUpdate version 2')
46+
update_file="dir1/file2.txt"# we'll use local_dir/dir1/file2.txt
47+
withopen(f"{local_dir}/{update_file}","a")asf:
48+
f.write("\nUpdate version 2")
5049
# ![2-test_cloned_repo_object]
5150

5251
# [3-test_cloned_repo_object]
@@ -82,7 +81,7 @@ def test_cloned_repo_object(self, local_dir):
8281

8382
# Untracked files - create new file
8483
# [7-test_cloned_repo_object]
85-
f=open(f'{local_dir}/untracked.txt','w')# creates an empty file
84+
f=open(f"{local_dir}/untracked.txt","w")# creates an empty file
8685
f.close()
8786
# ![7-test_cloned_repo_object]
8887

@@ -95,8 +94,8 @@ def test_cloned_repo_object(self, local_dir):
9594
# [9-test_cloned_repo_object]
9695
# Let's modify one of our tracked files
9796

98-
withopen(f'{local_dir}/Downloads/file3.txt','w')asf:
99-
f.write('file3 version 2')# overwrite file 3
97+
withopen(f"{local_dir}/Downloads/file3.txt","w")asf:
98+
f.write("file3 version 2")# overwrite file 3
10099
# ![9-test_cloned_repo_object]
101100

102101
# [10-test_cloned_repo_object]
@@ -126,7 +125,7 @@ def test_cloned_repo_object(self, local_dir):
126125
# ![11.1-test_cloned_repo_object]
127126
# [11.2-test_cloned_repo_object]
128127
# lets add untracked.txt
129-
repo.index.add(['untracked.txt'])
128+
repo.index.add(["untracked.txt"])
130129
diffs=repo.index.diff(repo.head.commit)
131130
fordindiffs:
132131
print(d.a_path)
@@ -146,9 +145,7 @@ def test_cloned_repo_object(self, local_dir):
146145
# dir1/file2.txt
147146
# ![11.3-test_cloned_repo_object]
148147

149-
150-
151-
'''Trees and Blobs'''
148+
"""Trees and Blobs"""
152149

153150
# Latest commit tree
154151
# [12-test_cloned_repo_object]
@@ -195,7 +192,7 @@ def print_files_from_git(root, level=0):
195192

196193
# Printing text files
197194
# [17-test_cloned_repo_object]
198-
print_file='dir1/file2.txt'
195+
print_file="dir1/file2.txt"
199196
tree[print_file]# the head commit tree
200197

201198
# Output <git.Blob "SHA1-HEX-HASH">
@@ -221,4 +218,4 @@ def print_files_from_git(root, level=0):
221218

222219
# Output
223220
# file 2 version 1
224-
# ![18.1-test_cloned_repo_object]
221+
# ![18.1-test_cloned_repo_object]

‎test/test_repo.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ def test_clone_from_with_path_contains_unicode(self):
251251
self.fail("Raised UnicodeEncodeError")
252252

253253
@with_rw_directory
254-
@skip("the referenced repository was removed, and one needs to setup a new password controlled repo under the orgs control")
254+
@skip(
255+
"the referenced repository was removed, and one needs to setup a new password controlled repo under the orgs control"
256+
)
255257
deftest_leaking_password_in_clone_logs(self,rw_dir):
256258
password="fakepassword1234"
257259
try:
@@ -391,7 +393,9 @@ def test_clone_from_unsafe_options_allowed(self, rw_repo):
391393
fori,unsafe_optioninenumerate(unsafe_options):
392394
destination=tmp_dir/str(i)
393395
assertnotdestination.exists()
394-
Repo.clone_from(rw_repo.working_dir,destination,multi_options=[unsafe_option],allow_unsafe_options=True)
396+
Repo.clone_from(
397+
rw_repo.working_dir,destination,multi_options=[unsafe_option],allow_unsafe_options=True
398+
)
395399
assertdestination.exists()
396400

397401
@with_rw_repo("HEAD")
@@ -755,8 +759,8 @@ def test_blame_complex_revision(self, git):
755759
@mock.patch.object(Git,"_call_process")
756760
deftest_blame_accepts_rev_opts(self,git):
757761
res=self.rorepo.blame("HEAD","README.md",rev_opts=["-M","-C","-C"])
758-
expected_args= ['blame','HEAD','-M','-C','-C','--','README.md']
759-
boilerplate_kwargs= {"p":True,"stdout_as_string":False}
762+
expected_args= ["blame","HEAD","-M","-C","-C","--","README.md"]
763+
boilerplate_kwargs= {"p":True,"stdout_as_string":False}
760764
git.assert_called_once_with(*expected_args,**boilerplate_kwargs)
761765

762766
@skipIf(
@@ -1415,14 +1419,16 @@ def test_ignored_items_reported(self):
14151419

14161420
gi=tmp_dir/"repo"/".gitignore"
14171421

1418-
withopen(gi,'w')asfile:
1419-
file.write('ignored_file.txt\n')
1420-
file.write('ignored_dir/\n')
1422+
withopen(gi,"w")asfile:
1423+
file.write("ignored_file.txt\n")
1424+
file.write("ignored_dir/\n")
14211425

1422-
asserttemp_repo.ignored(['included_file.txt','included_dir/file.txt'])== []
1423-
asserttemp_repo.ignored(['ignored_file.txt'])== ['ignored_file.txt']
1424-
asserttemp_repo.ignored(['included_file.txt','ignored_file.txt'])== ['ignored_file.txt']
1425-
asserttemp_repo.ignored(['included_file.txt','ignored_file.txt','included_dir/file.txt','ignored_dir/file.txt'])== ['ignored_file.txt','ignored_dir/file.txt']
1426+
asserttemp_repo.ignored(["included_file.txt","included_dir/file.txt"])== []
1427+
asserttemp_repo.ignored(["ignored_file.txt"])== ["ignored_file.txt"]
1428+
asserttemp_repo.ignored(["included_file.txt","ignored_file.txt"])== ["ignored_file.txt"]
1429+
asserttemp_repo.ignored(
1430+
["included_file.txt","ignored_file.txt","included_dir/file.txt","ignored_dir/file.txt"]
1431+
)== ["ignored_file.txt","ignored_dir/file.txt"]
14261432

14271433
deftest_ignored_raises_error_w_symlink(self):
14281434
withtempfile.TemporaryDirectory()astdir:

‎test/test_submodule.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ def _patch_git_config(name, value):
3939

4040
# This is recomputed each time the context is entered, for compatibility with
4141
# existing GIT_CONFIG_* environment variables, even if changed in this process.
42-
patcher=mock.patch.dict(os.environ, {
43-
"GIT_CONFIG_COUNT":str(pair_index+1),
44-
f"GIT_CONFIG_KEY_{pair_index}":name,
45-
f"GIT_CONFIG_VALUE_{pair_index}":value,
46-
})
42+
patcher=mock.patch.dict(
43+
os.environ,
44+
{
45+
"GIT_CONFIG_COUNT":str(pair_index+1),
46+
f"GIT_CONFIG_KEY_{pair_index}":name,
47+
f"GIT_CONFIG_VALUE_{pair_index}":value,
48+
},
49+
)
4750

4851
withpatcher:
4952
yield
@@ -914,17 +917,17 @@ def test_ignore_non_submodule_file(self, rwdir):
914917
os.mkdir(smp)
915918

916919
withopen(osp.join(smp,"a"),"w",encoding="utf-8")asf:
917-
f.write('test\n')
920+
f.write("test\n")
918921

919922
withopen(osp.join(rwdir,".gitmodules"),"w",encoding="utf-8")asf:
920-
f.write("[submodule\"a\"]\n")
923+
f.write('[submodule"a"]\n')
921924
f.write(" path = module\n")
922925
f.write(" url = https://github.com/chaconinc/DbConnector\n")
923926

924927
parent.git.add(Git.polish_url(osp.join(smp,"a")))
925928
parent.git.add(Git.polish_url(osp.join(rwdir,".gitmodules")))
926929

927-
parent.git.commit(message='test')
930+
parent.git.commit(message="test")
928931

929932
assertlen(parent.submodules)==0
930933

@@ -1200,7 +1203,12 @@ def test_submodule_add_unsafe_options_allowed(self, rw_repo):
12001203
# The options will be allowed, but the command will fail.
12011204
withself.assertRaises(GitCommandError):
12021205
Submodule.add(
1203-
rw_repo,"new","new",str(tmp_dir),clone_multi_options=[unsafe_option],allow_unsafe_options=True
1206+
rw_repo,
1207+
"new",
1208+
"new",
1209+
str(tmp_dir),
1210+
clone_multi_options=[unsafe_option],
1211+
allow_unsafe_options=True,
12041212
)
12051213
assertnottmp_file.exists()
12061214

@@ -1211,7 +1219,12 @@ def test_submodule_add_unsafe_options_allowed(self, rw_repo):
12111219
forunsafe_optioninunsafe_options:
12121220
withself.assertRaises(GitCommandError):
12131221
Submodule.add(
1214-
rw_repo,"new","new",str(tmp_dir),clone_multi_options=[unsafe_option],allow_unsafe_options=True
1222+
rw_repo,
1223+
"new",
1224+
"new",
1225+
str(tmp_dir),
1226+
clone_multi_options=[unsafe_option],
1227+
allow_unsafe_options=True,
12151228
)
12161229

12171230
@with_rw_repo("HEAD")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp