Skip to content

Commit

Permalink
LogPrinterTest: Strip to 79 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
sils committed Apr 8, 2015
1 parent 95ba88c commit bda9925
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions coalib/tests/output/printers/LogPrinterTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,54 @@ def _print(self, output, special_arg="test"):


class LogPrinterTestCase(unittest.TestCase):
log_message = LogMessage(LOG_LEVEL.ERROR, StringConstants.COMPLEX_TEST_STRING)
log_message = LogMessage(LOG_LEVEL.ERROR,
StringConstants.COMPLEX_TEST_STRING)

def test_interface(self):
uut = LogPrinter()
self.assertRaises(NotImplementedError, uut.log_message, self.log_message)
self.assertRaises(NotImplementedError,
uut.log_message,
self.log_message)

def test_logging(self):
uut = TestLogPrinter(timestamp_format="")
self.assertEqual((str(self.log_message), "special"),
uut.log_message(self.log_message, end="", special_arg="special"))
self.assertEqual(
(str(self.log_message), "special"),
uut.log_message(self.log_message, end="", special_arg="special"))

uut = TestLogPrinter(log_level=LOG_LEVEL.DEBUG)
ts = datetime.today()
self.assertEqual(
("[" + _("ERROR") + "][" + ts.strftime("%X") + "] " + StringConstants.COMPLEX_TEST_STRING, "test"),
("[" + _("ERROR") + "][" + ts.strftime("%X") + "] " +
StringConstants.COMPLEX_TEST_STRING, "test"),

This comment has been minimized.

Copy link
@Makman2

Makman2 Apr 8, 2015

Member

no indentation by 4 spaces?

This comment has been minimized.

Copy link
@sils

sils Apr 8, 2015

Author Member

it is. Plus bracket.

This comment has been minimized.

Copy link
@Makman2

Makman2 Apr 8, 2015

Member

So not like:

self.assertEqual(
    ("[" + _("ERROR") + "][" + ts.strftime("%X") + "] " +
        StringConstants.COMPLEX_TEST_STRING, "test")
...

This comment has been minimized.

Copy link
@sils

sils Apr 8, 2015

Author Member

no, this is aligned with the previous line. Otherwise it would be

(
    first part
    second part)

This comment has been minimized.

Copy link
@Makman2

Makman2 Apr 8, 2015

Member

okay

uut.log_message(self.log_message, timestamp=ts, end=""))
self.assertEqual(
("[" + _("ERROR") + "][" + ts.strftime("%X") + "] " + StringConstants.COMPLEX_TEST_STRING, "test"),
uut.log(LOG_LEVEL.ERROR, StringConstants.COMPLEX_TEST_STRING, timestamp=ts, end=""))
("[" + _("ERROR") + "][" + ts.strftime("%X") + "] " +
StringConstants.COMPLEX_TEST_STRING, "test"),
uut.log(LOG_LEVEL.ERROR,
StringConstants.COMPLEX_TEST_STRING,
timestamp=ts,
end=""))

self.assertEqual(
("[" + _("DEBUG") + "][" + ts.strftime("%X") + "] " + StringConstants.COMPLEX_TEST_STRING, "test"),
uut.debug(StringConstants.COMPLEX_TEST_STRING, timestamp=ts, end=""))
("[" + _("DEBUG") + "][" + ts.strftime("%X") + "] " +
StringConstants.COMPLEX_TEST_STRING, "test"),
uut.debug(StringConstants.COMPLEX_TEST_STRING,
timestamp=ts,
end=""))
uut.log_level = LOG_LEVEL.WARNING
self.assertEqual(None, uut.debug(StringConstants.COMPLEX_TEST_STRING, timestamp=ts, end=""))
self.assertEqual(None, uut.debug(StringConstants.COMPLEX_TEST_STRING,
timestamp=ts,
end=""))
self.assertEqual(
("[" + _("WARNING") + "][" + ts.strftime("%X") + "] " + StringConstants.COMPLEX_TEST_STRING, "test"),
uut.warn(StringConstants.COMPLEX_TEST_STRING, timestamp=ts, end=""))
("[" + _("WARNING") + "][" + ts.strftime("%X") + "] " +
StringConstants.COMPLEX_TEST_STRING, "test"),
uut.warn(StringConstants.COMPLEX_TEST_STRING,
timestamp=ts,
end=""))
self.assertEqual(
("[" + _("ERROR") + "][" + ts.strftime("%X") + "] " + StringConstants.COMPLEX_TEST_STRING, "test"),
("[" + _("ERROR") + "][" + ts.strftime("%X") + "] " +
StringConstants.COMPLEX_TEST_STRING, "test"),
uut.err(StringConstants.COMPLEX_TEST_STRING, timestamp=ts, end=""))

logged = uut.log_exception(
Expand Down

1 comment on commit bda9925

@Makman2
Copy link
Member

@Makman2 Makman2 commented on bda9925 Apr 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then ack

Please sign in to comment.