[Python] Should I use a testing framework if I want to run a set of commands, record the...

Discussão em 'Python' iniciado por Stack, Outubro 2, 2024.

  1. Stack

    Stack Membro Participativo

    I'm a bit confused of the best method of doing this. Lets say I want to run a command on linux and store the output (I've thought of creating a JSON file and storing "runs" of when this command was last ran), and I want to then compare the command output against a previous run (I regex the output from the command dump and store that in the JSON section and can use this to compare to previous JSON inserts).

    Would using a testing framework for this be overkill?

    def test_01():
    result = run_command_on_linux()
    log_result(result)
    assert(...)


    I feel like a testing framework would be best for organizing running commands with different arguments, but I'm a bit hung up on what I would be asserting. I could create a function that compares the last two outputs in that JSON file, and return true if the last one is a better output, and then assert that.

    Continue reading...

Compartilhe esta Página