Merge pull request #322 from dnephin/fix_cli_for_py26

Fix cli for python 2.6
This commit is contained in:
Chris Corbyn 2014-07-27 18:35:40 +10:00
commit 0dc55fda45
4 changed files with 28 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
*.egg-info *.egg-info
*.pyc *.pyc
.tox
/build /build
/dist /dist
/docs/_site /docs/_site

View File

@ -24,16 +24,7 @@ log = logging.getLogger(__name__)
def main(): def main():
console_handler = logging.StreamHandler(stream=sys.stderr) setup_logging()
console_handler.setFormatter(logging.Formatter())
console_handler.setLevel(logging.INFO)
root_logger = logging.getLogger()
root_logger.addHandler(console_handler)
root_logger.setLevel(logging.DEBUG)
# Disable requests logging
logging.getLogger("requests").propagate = False
try: try:
command = TopLevelCommand() command = TopLevelCommand()
command.sys_dispatch() command.sys_dispatch()
@ -56,6 +47,18 @@ def main():
sys.exit(1) sys.exit(1)
def setup_logging():
console_handler = logging.StreamHandler(sys.stderr)
console_handler.setFormatter(logging.Formatter())
console_handler.setLevel(logging.INFO)
root_logger = logging.getLogger()
root_logger.addHandler(console_handler)
root_logger.setLevel(logging.DEBUG)
# Disable requests logging
logging.getLogger("requests").propagate = False
# stolen from docopt master # stolen from docopt master
def parse_doc_section(name, source): def parse_doc_section(name, source):
pattern = re.compile('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)', pattern = re.compile('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)',

View File

@ -1,9 +1,13 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from __future__ import absolute_import from __future__ import absolute_import
import logging
import os
from .. import unittest from .. import unittest
from fig.cli import main
from fig.cli.main import TopLevelCommand from fig.cli.main import TopLevelCommand
from fig.packages.six import StringIO from fig.packages.six import StringIO
import os
class CLITestCase(unittest.TestCase): class CLITestCase(unittest.TestCase):
def test_default_project_name(self): def test_default_project_name(self):
@ -35,3 +39,8 @@ class CLITestCase(unittest.TestCase):
command = TopLevelCommand() command = TopLevelCommand()
with self.assertRaises(SystemExit): with self.assertRaises(SystemExit):
command.dispatch(['-h'], None) command.dispatch(['-h'], None)
def test_setup_logging(self):
main.setup_logging()
self.assertEqual(logging.getLogger().level, logging.DEBUG)
self.assertEqual(logging.getLogger('requests').propagate, False)

View File

@ -2,7 +2,8 @@
envlist = py26,py27,py32,py33,pypy envlist = py26,py27,py32,py33,pypy
[testenv] [testenv]
deps =
-rrequirements.txt
-rrequirements-dev.txt
commands = commands =
pip install -e {toxinidir} nosetests {posargs}
pip install -e {toxinidir}[test]
python setup.py test