Exemple #1
0
    def test_eventAsTextTimestampOnly(self):
        """
        If includeTimestamp is specified as the only option no system or
        traceback are printed.
        """
        if tzset is None:
            raise SkipTest(
                "Platform cannot change timezone; unable to verify offsets.")

        addTZCleanup(self)
        setTZ("UTC+00")

        try:
            raise CapturedError("This is a fake error")
        except CapturedError:
            f = Failure()

        t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
        event = {
            "log_format": "ABCD",
            "log_system": "fake_system",
            "log_time": t,
        }
        event["log_failure"] = f
        eventText = eventAsText(
            event,
            includeTimestamp=True,
            includeTraceback=False,
            includeSystem=False,
        )
        self.assertEqual(
            eventText,
            "2013-09-24T11:40:47+0000 ABCD",
        )
Exemple #2
0
    def test_formatTimeDefault(self) -> None:
        """
        Time is first field.  Default time stamp format is RFC 3339 and offset
        respects the timezone as set by the standard C{TZ} environment variable
        and L{tzset} API.
        """
        if tzset is None:
            raise SkipTest("Platform cannot change timezone; unable to verify offsets.")

        addTZCleanup(self)
        setTZ("UTC+00")

        t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
        event = dict(log_format="XYZZY", log_time=t)
        self.assertEqual(
            formatEventAsClassicLogText(event),
            "2013-09-24T11:40:47+0000 [-\x23-] XYZZY\n",
        )
    def test_formatTimeDefault(self):
        """
        Time is first field.  Default time stamp format is RFC 3339 and offset
        respects the timezone as set by the standard C{TZ} environment variable
        and L{tzset} API.
        """
        if tzset is None:
            raise SkipTest(
                "Platform cannot change timezone; unable to verify offsets."
            )

        addTZCleanup(self)
        setTZ("UTC+00")

        t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
        event = dict(log_format=u"XYZZY", log_time=t)
        self.assertEqual(
            formatEventAsClassicLogText(event),
            u"2013-09-24T11:40:47+0000 [-#-] XYZZY\n",
        )
Exemple #4
0
 def setUp(self):
     addTZCleanup(self)
Exemple #5
0
 def setUp(self) -> None:
     addTZCleanup(self)
 def setUp(self):
     addTZCleanup(self)