Skip to content

23rd September 2021

Computer Science

Programming

Basics

  • New: str.count(sub[, start[, end]]).

    Return the number of non-overlapping occurrences of substring sub in the range [start, end].

pytest

  • New: Capture stdout/stderr output.

    Use the capfd fixture.

    Example:

    def test_foo(capfd):
        foo()  # Writes "Hello World!" to stdout
        out, err = capfd.readouterr()
        assert out == "Hello World!"