Skip to content
Discussion options

You must be logged in to vote

Is there something else I need to do to get it to work in unit tests? Mock a console?

I would recommend reading up on capturing output in xUnit.net documentation.

Capturing the logging from Python might need more work. One way is to obtain a ITestOutputHelper in your test class constructor:

public class CommunicationTests
{
    ITestOutputHelper _output;
    IPythonEnvironment _env;

    public CommunicationTests(ITestOutputHelper output)
    {
        _output = output;

        // rest of the method code...
    }
}

Then update the Python module to redirect to a stream backed by a string and adding another function (get_log below) to obtain its content like so:

import io
import logging
i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PhasonMatrix
Comment options

Answer selected by PhasonMatrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants