MCPcopy Index your code
hub / github.com/RustPython/RustPython / StdStreamComparer

Class StdStreamComparer

Lib/test/test_argparse.py:1835–1854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1833
1834
1835class StdStreamComparer:
1836 def __init__(self, attr):
1837 # We try to use the actual stdXXX.buffer attribute as our
1838 # marker, but but under some test environments,
1839 # sys.stdout/err are replaced by io.StringIO which won't have .buffer,
1840 # so we use a sentinel simply to show that the tests do the right thing
1841 # for any buffer supporting object
1842 self.getattr = operator.attrgetter(attr)
1843 if attr == 'stdout.buffer':
1844 self.backupattr = BIN_STDOUT_SENTINEL
1845 elif attr == 'stderr.buffer':
1846 self.backupattr = BIN_STDERR_SENTINEL
1847 else:
1848 self.backupattr = object() # Not equal to anything
1849
1850 def __eq__(self, other):
1851 try:
1852 return other == self.getattr(sys)
1853 except AttributeError:
1854 return other == self.backupattr
1855
1856
1857eq_stdin = StdStreamComparer('stdin')

Callers 1

test_argparse.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected