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

fix (test): almost equal.

parent 1b586eee
No related branches found
No related tags found
1 merge request!6Hotfix: fix to assert error post installation
Pipeline #3793 failed with stages
in 2 minutes and 9 seconds
...@@ -9,13 +9,17 @@ def test_sanity(capsys): ...@@ -9,13 +9,17 @@ def test_sanity(capsys):
assert len(version) >= 3, version assert len(version) >= 3, version
def almost_equal(s1, s2, threshold=0.9) -> bool:
assert SequenceMatcher(a=s1, b=s2).ratio() > threshold
def test_run_repeat(capsys): def test_run_repeat(capsys):
bconfig.set_config("plain", True) bconfig.set_config("plain", True)
bitia.__main__.run_user_input("ls -ltr /", rerun=False) bitia.__main__.run_user_input("ls -ltr /", rerun=False)
l1 = capsys.readouterr().out # reset the internal buffer. l1 = capsys.readouterr().out # reset the internal buffer.
bitia.__main__.run_user_input("ls -ltr /", rerun=False) bitia.__main__.run_user_input("ls -ltr /", rerun=False)
l2 = capsys.readouterr().out l2 = capsys.readouterr().out
assert l1 == l2 assert almost_equal(l1, l2, 0.95)
def test_run_simple(capsys): def test_run_simple(capsys):
...@@ -27,4 +31,4 @@ def test_run_simple(capsys): ...@@ -27,4 +31,4 @@ def test_run_simple(capsys):
bitia.__main__.run_user_input("ls -ltr /", rerun=True) bitia.__main__.run_user_input("ls -ltr /", rerun=True)
captured = capsys.readouterr() captured = capsys.readouterr()
l2 = captured.out l2 = captured.out
assert SequenceMatcher(a=l1, b=l2).ratio() > 0.88 # sometime its less than 0.9 assert almost_equal(l1, l2, 0.88)
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