-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_hash_object.py
More file actions
25 lines (20 loc) · 1.63 KB
/
test_hash_object.py
File metadata and controls
25 lines (20 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import subprocess
def test_hash_object():
# テスト用のファイルを作成
with open("hello.txt", "w") as f:
f.write("Hello, world!")
with open("hoge.txt", "w") as f:
f.write("hogehoge")
# テストケース1: -wオプションなしでファイル1つを指定
output = subprocess.check_output(["python", "git.py", "hash-object", "hello.txt"], universal_newlines=True).strip()
git_hash_output = subprocess.check_output(["git", "hash-object", "./hello.txt"], universal_newlines=True).strip()
assert output == git_hash_output, "Output mismatch: without the -w option, the output does not match the output of the git command"
# テストケース2: -wオプションありでファイル1つを指定
output = subprocess.check_output(["python", "git.py", "hash-object", "-w", "hello.txt"], universal_newlines=True).strip()
git_hash_output = subprocess.check_output(["git", "hash-object", "-w", "./hello.txt"], universal_newlines=True).strip()
assert output == git_hash_output, "Output mismatch: with the -w option, the output does not match the output of the git command"
# テストケース3: -wオプションなしで複数のファイルを指定
output = subprocess.check_output(["python", "git.py", "hash-object", "hello.txt", "hoge.txt"], universal_newlines=True).strip()
git_hash_output = subprocess.check_output(["git", "hash-object", "./hello.txt", "./hoge.txt"], universal_newlines=True).strip()
assert output == git_hash_output, "Output mismatch: without the -w option, the output does not match the output of the git command"
print("All tests passed successfully.")