Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Unified Diff: appengine/swarming/swarming_bot/logging_utils_test.py

Issue 1233303003: Migrate and merge logging_utils from swarming_bot into client/utils. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/swarming_bot/logging_utils_test.py
diff --git a/appengine/swarming/swarming_bot/logging_utils_test.py b/appengine/swarming/swarming_bot/logging_utils_test.py
deleted file mode 100755
index ac89ad3b4b4909f31b8e9af78a0aaefeef28e8ef..0000000000000000000000000000000000000000
--- a/appengine/swarming/swarming_bot/logging_utils_test.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2014 The Swarming Authors. All rights reserved.
-# Use of this source code is governed by the Apache v2.0 license that can be
-# found in the LICENSE file.
-
-import logging
-import os
-import sys
-import tempfile
-import shutil
-import unittest
-import re
-
-# Import this first before manipulating sys.path to ensure it can load fine.
-import logging_utils
-
-ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-sys.path.insert(0, ROOT_DIR)
-
-import test_env
-test_env.setup_test_env()
-
-from depot_tools import auto_stub
-
-_LOG_HEADER = r'^%s \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d\d\d: ' % os.getpid()
-
-
-class TestLoggingUtils(auto_stub.TestCase):
- def test_Capture(self):
- root = logging.RootLogger(logging.DEBUG)
- with logging_utils.CaptureLogs('foo', root) as log:
- root.debug('foo')
- result = log.read()
- self.assertTrue(re.match(_LOG_HEADER + 'DEBUG foo\n$', result), result)
-
- def test_prepare_logging(self):
- root = logging.RootLogger(logging.DEBUG)
- tmp_dir = tempfile.mkdtemp(prefix='logging_utils_test')
- try:
- filepath = os.path.join(tmp_dir, 'test.log')
- logging_utils.prepare_logging(filepath, root)
- root.debug('foo')
- with open(filepath, 'rb') as f:
- result = f.read()
- finally:
- shutil.rmtree(tmp_dir)
- # It'd be nice to figure out a way to ensure it's properly in UTC but it's
- # tricky to do reliably.
- self.assertTrue(re.match(_LOG_HEADER + 'DEBUG foo\n$', result), result)
-
-
-if __name__ == '__main__':
- unittest.main()

Powered by Google App Engine
This is Rietveld 408576698