Consistent black formatting of all Path python files

This commit is contained in:
Markus Lampert
2022-02-28 21:06:16 -08:00
parent 8583894284
commit 934b0aaa07
93 changed files with 5216 additions and 3118 deletions

View File

@@ -23,10 +23,11 @@
import PathScripts.PathLog as PathLog
import unittest
class TestPathLog(unittest.TestCase):
"""Some basic tests for the logging framework."""
MODULE = 'TestPathLog' # file name without extension
MODULE = "TestPathLog" # file name without extension
def setUp(self):
PathLog.setLevel(PathLog.Level.RESET)
@@ -34,8 +35,10 @@ class TestPathLog(unittest.TestCase):
def callerFile(self):
return PathLog._caller()[0]
def callerLine(self):
return PathLog._caller()[1]
def callerFunc(self):
return PathLog._caller()[2]
@@ -45,7 +48,7 @@ class TestPathLog(unittest.TestCase):
def test01(self):
"""Check for proper function extraction."""
self.assertEqual(self.callerFunc(), 'test01')
self.assertEqual(self.callerFunc(), "test01")
def test10(self):
"""Verify default log levels is NOTICE."""
@@ -69,7 +72,7 @@ class TestPathLog(unittest.TestCase):
def test13(self):
"""Verify setting other modul's log level doesn't change this one's."""
# if this test fails then most likely the global RESET is broken
PathLog.setLevel(PathLog.Level.DEBUG, 'SomeOtherModule')
PathLog.setLevel(PathLog.Level.DEBUG, "SomeOtherModule")
self.assertEqual(PathLog.getLevel(), PathLog.Level.NOTICE)
self.assertEqual(PathLog.getLevel(self.MODULE), PathLog.Level.NOTICE)
@@ -100,93 +103,93 @@ class TestPathLog(unittest.TestCase):
def test30(self):
"""Verify log level ERROR."""
PathLog.setLevel(PathLog.Level.ERROR)
self.assertIsNone(PathLog.debug('something'))
self.assertIsNone(PathLog.info('something'))
self.assertIsNone(PathLog.notice('something'))
self.assertIsNone(PathLog.warning('something'))
self.assertIsNotNone(PathLog.error('something'))
self.assertIsNone(PathLog.debug("something"))
self.assertIsNone(PathLog.info("something"))
self.assertIsNone(PathLog.notice("something"))
self.assertIsNone(PathLog.warning("something"))
self.assertIsNotNone(PathLog.error("something"))
def test31(self):
"""Verify log level WARNING."""
PathLog.setLevel(PathLog.Level.WARNING)
self.assertIsNone(PathLog.debug('something'))
self.assertIsNone(PathLog.info('something'))
self.assertIsNone(PathLog.notice('something'))
self.assertIsNotNone(PathLog.warning('something'))
self.assertIsNotNone(PathLog.error('something'))
self.assertIsNone(PathLog.debug("something"))
self.assertIsNone(PathLog.info("something"))
self.assertIsNone(PathLog.notice("something"))
self.assertIsNotNone(PathLog.warning("something"))
self.assertIsNotNone(PathLog.error("something"))
def test32(self):
"""Verify log level NOTICE."""
PathLog.setLevel(PathLog.Level.NOTICE)
self.assertIsNone(PathLog.debug('something'))
self.assertIsNone(PathLog.info('something'))
self.assertIsNotNone(PathLog.notice('something'))
self.assertIsNotNone(PathLog.warning('something'))
self.assertIsNotNone(PathLog.error('something'))
self.assertIsNone(PathLog.debug("something"))
self.assertIsNone(PathLog.info("something"))
self.assertIsNotNone(PathLog.notice("something"))
self.assertIsNotNone(PathLog.warning("something"))
self.assertIsNotNone(PathLog.error("something"))
def test33(self):
"""Verify log level INFO."""
PathLog.setLevel(PathLog.Level.INFO)
self.assertIsNone(PathLog.debug('something'))
self.assertIsNotNone(PathLog.info('something'))
self.assertIsNotNone(PathLog.notice('something'))
self.assertIsNotNone(PathLog.warning('something'))
self.assertIsNotNone(PathLog.error('something'))
self.assertIsNone(PathLog.debug("something"))
self.assertIsNotNone(PathLog.info("something"))
self.assertIsNotNone(PathLog.notice("something"))
self.assertIsNotNone(PathLog.warning("something"))
self.assertIsNotNone(PathLog.error("something"))
def test34(self):
"""Verify log level DEBUG."""
PathLog.setLevel(PathLog.Level.DEBUG)
self.assertIsNotNone(PathLog.debug('something'))
self.assertIsNotNone(PathLog.info('something'))
self.assertIsNotNone(PathLog.notice('something'))
self.assertIsNotNone(PathLog.warning('something'))
self.assertIsNotNone(PathLog.error('something'))
self.assertIsNotNone(PathLog.debug("something"))
self.assertIsNotNone(PathLog.info("something"))
self.assertIsNotNone(PathLog.notice("something"))
self.assertIsNotNone(PathLog.warning("something"))
self.assertIsNotNone(PathLog.error("something"))
def test50(self):
"""Verify no tracking by default."""
self.assertIsNone(PathLog.track('this', 'and', 'that'))
self.assertIsNone(PathLog.track("this", "and", "that"))
def test51(self):
"""Verify enabling tracking for module results in tracking."""
PathLog.trackModule()
# Don't want to rely on the line number matching - still want some
# indication that track does the right thing ....
msg = PathLog.track('this', 'and', 'that')
msg = PathLog.track("this", "and", "that")
self.assertTrue(msg.startswith(self.MODULE))
self.assertTrue(msg.endswith('test51(this, and, that)'))
self.assertTrue(msg.endswith("test51(this, and, that)"))
def test52(self):
"""Verify untracking stops tracking."""
PathLog.trackModule()
self.assertIsNotNone(PathLog.track('this', 'and', 'that'))
self.assertIsNotNone(PathLog.track("this", "and", "that"))
PathLog.untrackModule()
self.assertIsNone(PathLog.track('this', 'and', 'that'))
self.assertIsNone(PathLog.track("this", "and", "that"))
def test53(self):
"""Verify trackAllModules works correctly."""
PathLog.trackAllModules(True)
self.assertIsNotNone(PathLog.track('this', 'and', 'that'))
self.assertIsNotNone(PathLog.track("this", "and", "that"))
PathLog.trackAllModules(False)
self.assertIsNone(PathLog.track('this', 'and', 'that'))
self.assertIsNone(PathLog.track("this", "and", "that"))
PathLog.trackAllModules(True)
PathLog.trackModule()
self.assertIsNotNone(PathLog.track('this', 'and', 'that'))
self.assertIsNotNone(PathLog.track("this", "and", "that"))
PathLog.trackAllModules(False)
self.assertIsNotNone(PathLog.track('this', 'and', 'that'))
self.assertIsNotNone(PathLog.track("this", "and", "that"))
def test60(self):
"""Verify track handles no argument."""
PathLog.trackModule()
msg = PathLog.track()
self.assertTrue(msg.startswith(self.MODULE))
self.assertTrue(msg.endswith('test60()'))
self.assertTrue(msg.endswith("test60()"))
def test61(self):
"""Verify track handles arbitrary argument types correctly."""
PathLog.trackModule()
msg = PathLog.track('this', None, 1, 18.25)
msg = PathLog.track("this", None, 1, 18.25)
self.assertTrue(msg.startswith(self.MODULE))
self.assertTrue(msg.endswith('test61(this, None, 1, 18.25)'))
self.assertTrue(msg.endswith("test61(this, None, 1, 18.25)"))
def testzz(self):
"""Restoring environment after tests."""