def test_fromEnvironment(self):
        """
        L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter}
        instance with attributes populated from available modules.
        """
        formatter = _ErrorFormatter.fromEnvironment()

        if formatter.winError is not None:
            from ctypes import WinError
            self.assertEqual(
                formatter.formatError(self.probeErrorCode),
                WinError(self.probeErrorCode).strerror)
            formatter.winError = None

        if formatter.formatMessage is not None:
            from win32api import FormatMessage
            self.assertEqual(
                formatter.formatError(self.probeErrorCode),
                FormatMessage(self.probeErrorCode))
            formatter.formatMessage = None

        if formatter.errorTab is not None:
            from socket import errorTab
            self.assertEqual(
                formatter.formatError(self.probeErrorCode),
                errorTab[self.probeErrorCode])
示例#2
0
    def test_fromEnvironment(self):
        """
        L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter}
        instance with attributes populated from available modules.
        """
        formatter = _ErrorFormatter.fromEnvironment()

        if formatter.winError is not None:
            from ctypes import WinError
            self.assertEqual(
                formatter.formatError(self.probeErrorCode),
                WinError(self.probeErrorCode).strerror)
            formatter.winError = None

        if formatter.formatMessage is not None:
            from win32api import FormatMessage
            self.assertEqual(
                formatter.formatError(self.probeErrorCode),
                FormatMessage(self.probeErrorCode))
            formatter.formatMessage = None

        if formatter.errorTab is not None:
            from socket import errorTab
            self.assertEqual(
                formatter.formatError(self.probeErrorCode),
                errorTab[self.probeErrorCode])