Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some extra logging and options tests

  • Loading branch information...
commit 588fb6f25e1bc2a33ddf905456fdfe3e3b7fb044 1 parent 39b2aaf
Marcus Smith authored
9 tests/unit/test_basecommand.py
View
@@ -70,3 +70,12 @@ def test_log_log_file(self, tmpdir):
cmd.main(['fake', '--log', log_path, '--log-file', log_file_path])
assert 'fake' == open(log_path).read().strip()[:4]
assert 'fake' == open(log_file_path).read().strip()[:4]
+
+ def test_verbose_quiet(self):
+ """
+ Test additive quality of -v and -q
+ """
+ cmd = FakeCommand()
+ cmd.main(['fake', '-vqq'])
+ console_level = logger.consumers[0][0]
+ assert console_level == logger.WARN
11 tests/unit/test_log.py
View
@@ -61,3 +61,14 @@ def test_log_no_extra_line_break():
assert 1 == len(consumer1.getvalue().splitlines(True))
assert 1 == len(consumer2.getvalue().splitlines(True))
+def test_level_for_integer():
+ logger = Logger()
+ assert logger.VERBOSE_DEBUG == logger.level_for_integer(-1000)
+ assert logger.VERBOSE_DEBUG == logger.level_for_integer(0)
+ assert logger.DEBUG == logger.level_for_integer(1)
+ assert logger.INFO == logger.level_for_integer(2)
+ assert logger.NOTIFY == logger.level_for_integer(3)
+ assert logger.WARN == logger.level_for_integer(4)
+ assert logger.ERROR == logger.level_for_integer(5)
+ assert logger.FATAL == logger.level_for_integer(6)
+ assert logger.FATAL == logger.level_for_integer(1000)
13 tests/unit/test_options.py
View
@@ -75,6 +75,19 @@ def test_env_override_default_choice(self):
options, args = main(['fake'])
assert options.exists_action == ['s', 'w']
+ def test_env_alias_override_default(self):
+ """
+ When an option has multiple long forms, test that the technique of using
+ the env variable, "PIP_<long form>" works for all cases.
+ (e.g. PIP_LOG_FILE and PIP_LOCAL_LOG should all work)
+ """
+ os.environ['PIP_LOG_FILE'] = 'override.log'
+ options, args = main(['fake'])
+ assert options.log_file == 'override.log'
+ os.environ['PIP_LOCAL_LOG'] = 'override.log'
+ options, args = main(['fake'])
+ assert options.log_file == 'override.log'
+
def test_cli_override_environment(self):
"""
Test the cli overrides and environment variable
Please sign in to comment.
Something went wrong with that request. Please try again.