/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-17 17:34:07 UTC
  • Revision ID: teddy@recompile.se-20190317173407-itlj1a7mzfwb3yz3
mandos-ctl: Refactor tests

* mandos-ctl: Change all calls to assertEqual (and related functions
              assertNotEqual and assertDictEqual) to always pass
              arguments in (expected, actual) order, for consistency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
962
962
    @staticmethod
963
963
    @contextlib.contextmanager
964
964
    def redirect_stderr_to_devnull():
965
 
        old_stderr = sys.stderr
966
 
        with contextlib.closing(open(os.devnull, "w")) as null:
967
 
            sys.stderr = null
968
 
            try:
969
 
                yield
970
 
            finally:
971
 
                sys.stderr = old_stderr
 
965
        null = os.open(os.path.devnull, os.O_RDWR)
 
966
        stderrcopy = os.dup(sys.stderr.fileno())
 
967
        os.dup2(null, sys.stderr.fileno())
 
968
        os.close(null)
 
969
        try:
 
970
            yield
 
971
        finally:
 
972
            # restore stderr
 
973
            os.dup2(stderrcopy, sys.stderr.fileno())
 
974
            os.close(stderrcopy)
972
975
 
973
976
    def check_option_syntax(self, options):
974
977
        check_option_syntax(self.parser, options)