MCPcopy Index your code
hub / github.com/python/cpython / StdStreamComparer

Class StdStreamComparer

Lib/test/test_argparse.py:1934–1953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1932
1933
1934class StdStreamComparer:
1935 def __init__(self, attr):
1936 # We try to use the actual stdXXX.buffer attribute as our
1937 # marker, but under some test environments,
1938 # sys.stdout/err are replaced by io.StringIO which won't have .buffer,
1939 # so we use a sentinel simply to show that the tests do the right thing
1940 # for any buffer supporting object
1941 self.getattr = operator.attrgetter(attr)
1942 if attr == 'stdout.buffer':
1943 self.backupattr = BIN_STDOUT_SENTINEL
1944 elif attr == 'stderr.buffer':
1945 self.backupattr = BIN_STDERR_SENTINEL
1946 else:
1947 self.backupattr = object() # Not equal to anything
1948
1949 def __eq__(self, other):
1950 try:
1951 return other == self.getattr(sys)
1952 except AttributeError:
1953 return other == self.backupattr
1954
1955
1956eq_stdin = StdStreamComparer('stdin')

Callers 1

test_argparse.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…