Skip to content
Snippets Groups Projects
Commit b653d925 authored by dilawar's avatar dilawar :ant:
Browse files

fix: Typos and tests fixes

Create a temp directory and save test data there.
parent 64d41486
No related branches found
No related tags found
1 merge request!6Hotfix: fix to assert error post installation
Pipeline #3784 failed with stages
in 2 minutes and 8 seconds
from bitia.__main__ import run_user_input
def test_cli_sanity():
lines = []
for line in run_user_input("ls -ltr /", output_lines=lines):
print(11, line)
assert len(lines) > 10, "Too few lines"
if __name__ == "__main__":
test_cli_sanity()
......@@ -11,24 +11,24 @@ _common_hashes = {
def test_filehash():
tempdir = tempfile.gettempdir()
f1 = Path(tempdir) / "a.txt"
f2 = Path(tempdir) / "b.txt"
for _c, _h in _common_hashes.items():
f1.write_text(_c)
assert f1.read_text() == _c
print(f"Computing hash of {f1}, content: {_c}")
assert sha256sum(f1) == _h
t1 = "ls -ltrh /"
f1.write_text(t1)
f2.write_text(t1)
assert sha256sum(f1) == sha256sum(f2)
t2 = "ls -ltrh"
f2.write_text(t2)
assert sha256sum(f1) != sha256sum(f2)
f1.write_text(t2)
assert sha256sum(f1) == sha256sum(f2)
with tempfile.TemporaryDirectory() as tempdir:
f1 = Path(tempdir) / "a.txt"
f2 = Path(tempdir) / "b.txt"
for _c, _h in _common_hashes.items():
f1.write_text(_c)
assert f1.read_text() == _c
print(f"Computing hash of {f1}, content: {_c}")
assert sha256sum(f1) == _h
t1 = "ls -ltrh /"
f1.write_text(t1)
f2.write_text(t1)
assert sha256sum(f1) == sha256sum(f2)
t2 = "ls -ltrh"
f2.write_text(t2)
assert sha256sum(f1) != sha256sum(f2)
f1.write_text(t2)
assert sha256sum(f1) == sha256sum(f2)
......@@ -18,4 +18,4 @@ def test_run_simple(capsys):
bitia.__main__.run_user_input("ls -ltr /", rerun=True)
captured = capsys.readouterr()
l2 = captured.out
assert SequenceMatcher(a=l1, b=l2).ratio() > 0.plain9
assert SequenceMatcher(a=l1, b=l2).ratio() > 0.9
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment