Dieter Maurer <die...@handshake.de> writes: > Loris Bennett wrote at 2022-3-10 13:16 +0100: >>I have a command which produces output like the >>following: >> >> Job ID: 9431211 >> Cluster: curta >> User/Group: build/staff >> State: COMPLETED (exit code 0) >> Nodes: 1 >> Cores per node: 8 >> CPU Utilized: 01:30:53 >> CPU Efficiency: 83.63% of 01:48:40 core-walltime >> Job Wall-clock time: 00:13:35 >> Memory Utilized: 6.45 GB >> Memory Efficiency: 80.68% of 8.00 GB >> >>I want to parse this and am using subprocess.Popen and accessing the >>contents via Popen.stdout. However, for testing purposes I want to save >>various possible outputs of the command as text files and use those as >>inputs. > > What do you want to test? the parsing? the "popen" interaction? > You can separately test both tasks (I, at your place, would do this).
I just want to test the parsing. > For the parsing test, it is not relevant that the actual text > comes from an external process. You can directly read it from a file > or have it in your text. As mentioned in the original post, for the tests I indeed want to read the input from files. > In my view, you do not need a test for the `Popen` interaction: > if it works once, it will work always. Sorry if I was unclear but my question is: Given that the return value from Popen is a Popen object and given that the return value from reading a file is a single string or maybe a list of strings, what should the common format for the argument which is passed to the actual parsing function be? Cheers, Loris -- This signature is currently under construction. -- https://mail.python.org/mailman/listinfo/python-list