| 1932 | |
| 1933 | |
| 1934 | class 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 | |
| 1956 | eq_stdin = StdStreamComparer('stdin') |
no outgoing calls
no test coverage detected
searching dependent graphs…