Skip to content
Snippets Groups Projects
  • Todd Gamblin's avatar
    7b8e5c89
    bugfix: don't use sys.stdout as a default arg value (#16541) · 7b8e5c89
    Todd Gamblin authored
    After migrating to `travis-ci.com`, we saw I/O issues in our tests --
    tests that relied on `capfd` and `capsys` were failing. We've also seen
    this in GitHub actions, and it's kept us from switching to them so far.
    
    Turns out that the issue is that using streams like `sys.stdout` as
    default arguments doesn't play well with `pytest` and output redirection,
    as `pytest` changes the values of `sys.stdout` and `sys.stderr`. if these
    values are evaluated before output redirection (as they are when used as
    default arg values), output won't be captured properly later.
    
    - [x] replace all stream default arg values with `None`, and only assign stream
          values inside functions.
    - [x] fix tests we didn't notice were relying on this erroneous behavior
    7b8e5c89
    History
    bugfix: don't use sys.stdout as a default arg value (#16541)
    Todd Gamblin authored
    After migrating to `travis-ci.com`, we saw I/O issues in our tests --
    tests that relied on `capfd` and `capsys` were failing. We've also seen
    this in GitHub actions, and it's kept us from switching to them so far.
    
    Turns out that the issue is that using streams like `sys.stdout` as
    default arguments doesn't play well with `pytest` and output redirection,
    as `pytest` changes the values of `sys.stdout` and `sys.stderr`. if these
    values are evaluated before output redirection (as they are when used as
    default arg values), output won't be captured properly later.
    
    - [x] replace all stream default arg values with `None`, and only assign stream
          values inside functions.
    - [x] fix tests we didn't notice were relying on this erroneous behavior