Update tests and logging

This commit is contained in:
Leandro Toledo 2015-08-09 09:59:41 -03:00
parent 66aaaf9ec0
commit 09ffd28df5
3 changed files with 22 additions and 8 deletions

View file

@ -32,7 +32,9 @@ Table of contents
1. `API`_ 1. `API`_
2. `Examples`_ 2. `Logging`_
3. `Examples`_
- `Contact`_ - `Contact`_
@ -191,9 +193,19 @@ There are many more API methods, to read the full API documentation::
$ pydoc telegram.Bot $ pydoc telegram.Bot
To get a verbose mode to debug:: -----------
_`Logging`
-----------
>>> telegram.Bot('token', debug=True) You can get logs in your main application by calling `logging` and setting the log level you want::
>>> import logging
>>> logger = logging.getLogger()
>>> logger.setLevel(logging.INFO)
If you want DEBUG logs instead::
>>> logger.setLevel(logging.DEBUG)
----------- -----------
_`Examples` _`Examples`

View file

@ -5,5 +5,7 @@ from tests.test_bot import BotTest
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig( logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
testsuite = unittest.TestLoader().loadTestsFromTestCase(BotTest) testsuite = unittest.TestLoader().loadTestsFromTestCase(BotTest)
unittest.TextTestRunner(verbosity=1).run(testsuite) unittest.TextTestRunner(verbosity=1).run(testsuite)

View file

@ -7,7 +7,7 @@ import unittest
class BotTest(unittest.TestCase): class BotTest(unittest.TestCase):
def setUp(self): def setUp(self):
bot = telegram.Bot(token=os.environ.get('TOKEN'), debug=True) bot = telegram.Bot(token=os.environ.get('TOKEN'))
self._bot = bot self._bot = bot
print('Testing the Bot API class') print('Testing the Bot API class')