So, adding automated remote station location updates to the code that tracks the Reverse Beacon Network spots of the KD0FNR Rockmite has become a bit of an oddysey, but here's more cool stuff:
The output python script new_key_cat.py is supposed to present only lines of output (to stdout) that do not contain keys that already exist in rm_rnb_history_pres.csv. Tests are being built for the script using pytest. pytest mutes stdin because the tests are intended to be automated rather than interactive. This makes sense to me, so I'm changing the method in the script that handles input to look for a file name argument, and if it doesn't have one to use stdin.
The second issue though was how to write an automated test case that looks at stdout. It turns out pytest has that covered. It's all written up at
https://docs.pytest.org/en/7.1.x/how-to/capture-stdout-stderr.html
And here's the pertinent code example from that page:
def test_myoutput(capsys): # or use "capfd" for fd-level print("hello") sys.stderr.write("world\n") captured = capsys.readouterr() assert captured.out == "hello\n" assert captured.err == "world\n" print("next") captured = capsys.readouterr() assert captured.out == "next\n"
def test_new_key_cat_2(capsys): # or use "capfd" for fd-level
new_key_cat("testfile_with_existing_keys")
captured = capsys.readouterr()
assert not captured.out.find("existing_key_1")
def test_new_key_cat_2(capsys): # or use "capfd" for fd-level new_key_cat("testfile_with_existing_keys") captured = capsys.readouterr() for entry in make_key_list("rm_rnb_history_pres.csv"): assert not captured.out.find(entry)
Comments
Post a Comment
Please leave your comments on this topic: