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

Commitacfee98

Browse files
committed
improve unit test
1 parent74ff8e5 commitacfee98

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

‎test/fixtures/index_extended_flags‎

436 Bytes
Binary file not shown.

‎test/test_index.py‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,30 +1218,48 @@ def test_index_add_non_normalized_path(self, rw_repo):
12181218

12191219
rw_repo.index.add(non_normalized_path)
12201220

1221+
deftest_index_file_v3(self):
1222+
index=IndexFile(self.rorepo,fixture_path("index_extended_flags"))
1223+
assertindex.entries
1224+
assertindex.version==3
1225+
assertlen(index.entries)==4
1226+
assertindex.entries[('init.t',0)].skip_worktree
1227+
1228+
# Write the data - it must match the original.
1229+
tmpfile=tempfile.mktemp()
1230+
index.write(tmpfile)
1231+
assertPath(tmpfile).read_bytes()==Path(fixture_path("index_extended_flags")).read_bytes()
1232+
os.remove(tmpfile)
1233+
12211234
@with_rw_directory
1222-
deftest_index_version_v3(self,tmp_dir):
1235+
deftest_index_file_v3_with_git_command(self,tmp_dir):
12231236
tmp_dir=Path(tmp_dir)
12241237
withcwd(tmp_dir):
1225-
subprocess.run(["git","init","-q"],check=True)
1238+
git=Git(tmp_dir)
1239+
git.init()
1240+
12261241
file=tmp_dir/"file.txt"
12271242
file.write_text("hello")
1228-
subprocess.run(["git","add","-N","file.txt"],check=True)
1243+
git.add("--intent-to-add","file.txt")# intent-to-add sets extended flag
12291244

12301245
repo=Repo(tmp_dir)
1246+
index=repo.index
12311247

1232-
assertlen(repo.index.entries)==1
1233-
entry=list(repo.index.entries.values())[0]
1248+
assertlen(index.entries)==1
1249+
assertindex.version==3
1250+
entry=list(index.entries.values())[0]
12341251
assertentry.path=="file.txt"
12351252
assertentry.intent_to_add
12361253

12371254
file2=tmp_dir/"file2.txt"
12381255
file2.write_text("world")
1239-
repo.index.add(["file2.txt"])
1240-
repo.index.write()
1256+
index.add(["file2.txt"])
1257+
index.write()
12411258

1242-
status_str=subprocess.check_output(["git","status","--porcelain"],text=True)
1243-
assert" A file.txt\n"instatus_str
1244-
assert"A file2.txt\n"instatus_str
1259+
status_str=git.status(porcelain=True)
1260+
status_lines=status_str.splitlines()
1261+
assert" A file.txt"instatus_lines
1262+
assert"A file2.txt"instatus_lines
12451263

12461264

12471265
classTestIndexUtils:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp