From 00bba73673b700d84ca9f642e237e550f6d91bb0 Mon Sep 17 00:00:00 2001 From: Rahiel Kasim Date: Sat, 20 Aug 2016 22:01:07 +0200 Subject: [PATCH] drop Python 2.6 support (closes #245) (#386) * drop Python 2.6 support (closes #245) * fix NullHandler import * README: explicitly mention Py3 and PyPy compatibility --- .travis.yml | 3 +- README.rst | 3 +- requirements-dev.txt | 1 - setup.py | 1 - telegram/__init__.py | 14 +++----- telegram/bot.py | 4 +-- telegram/contrib/botan.py | 3 +- telegram/ext/dispatcher.py | 4 +-- telegram/ext/updater.py | 4 +-- telegram/nullhandler.py | 32 ------------------- telegram/utils/webhookhandler.py | 4 +-- tests/test_bot.py | 6 +--- tests/test_choseninlineresult.py | 6 +--- tests/test_constants.py | 6 +--- tests/test_conversationhandler.py | 6 +--- tests/test_inlinekeyboardbutton.py | 6 +--- tests/test_inlinequery.py | 6 +--- tests/test_inlinequeryresultarticle.py | 6 +--- tests/test_inlinequeryresultaudio.py | 6 +--- tests/test_inlinequeryresultcachedaudio.py | 6 +--- tests/test_inlinequeryresultcacheddocument.py | 6 +--- tests/test_inlinequeryresultcachedgif.py | 6 +--- tests/test_inlinequeryresultcachedmpeg4gif.py | 6 +--- tests/test_inlinequeryresultcachedphoto.py | 6 +--- tests/test_inlinequeryresultcachedsticker.py | 6 +--- tests/test_inlinequeryresultcachedvideo.py | 6 +--- tests/test_inlinequeryresultcachedvoice.py | 6 +--- tests/test_inlinequeryresultcontact.py | 6 +--- tests/test_inlinequeryresultdocument.py | 6 +--- tests/test_inlinequeryresultgif.py | 6 +--- tests/test_inlinequeryresultlocation.py | 6 +--- tests/test_inlinequeryresultmpeg4gif.py | 6 +--- tests/test_inlinequeryresultphoto.py | 6 +--- tests/test_inlinequeryresultvenue.py | 6 +--- tests/test_inlinequeryresultvideo.py | 6 +--- tests/test_inlinequeryresultvoice.py | 6 +--- tests/test_inputcontactmessagecontent.py | 6 +--- tests/test_inputlocationmessagecontent.py | 6 +--- tests/test_inputmessagecontent.py | 6 +--- tests/test_inputtextmessagecontent.py | 6 +--- tests/test_inputvenuemessagecontent.py | 6 +--- tests/test_jobqueue.py | 6 +--- tests/test_keyboardbutton.py | 6 +--- tests/test_messageentity.py | 6 +--- tests/test_replymarkup.py | 6 +--- tests/test_updater.py | 6 +--- tests/test_venue.py | 6 +--- 47 files changed, 51 insertions(+), 238 deletions(-) delete mode 100644 telegram/nullhandler.py diff --git a/.travis.yml b/.travis.yml index 5e0a6dcb3..074ef32e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python python: - - "2.6" - "2.7" - "3.3" - "3.4" @@ -13,6 +12,6 @@ install: - pip install -r requirements-dev.txt script: - nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/ - - 'if [ $TRAVIS_PYTHON_VERSION != 2.6 ] && [ $TRAVIS_PYTHON_VERSION != 3.3 ] && [ $TRAVIS_PYTHON_VERSION != pypy3 ]; then pre-commit run --all-files; fi' + - 'if [ $TRAVIS_PYTHON_VERSION != 3.3 ] && [ $TRAVIS_PYTHON_VERSION != pypy3 ]; then pre-commit run --all-files; fi' after_success: coveralls diff --git a/README.rst b/README.rst index c1c2c1da9..4fdc17fd7 100644 --- a/README.rst +++ b/README.rst @@ -73,8 +73,7 @@ Introduction This library provides a pure Python interface for the `Telegram Bot API `_. -It works with Python versions from 2.6+ (**Note:** Support for 2.6 will be dropped at some point -this year. 2.7 will still be supported). +It's compatible with Python versions 2.7, 3.3+ and `PyPy `_. It also works with `Google App Engine `_. In addition to the pure API implementation, this library features a number of high-level classes to diff --git a/requirements-dev.txt b/requirements-dev.txt index ae6f0047e..318fbb0c8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,6 @@ flake8 nose pep257 pylint -unittest2 flaky yapf pre-commit diff --git a/setup.py b/setup.py index 39a19f992..c538f9ad5 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,6 @@ with codecs.open('README.rst', 'r', 'utf-8') as fd: 'Topic :: Internet', 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', diff --git a/telegram/__init__.py b/telegram/__init__.py index 0d52992dc..9b7b19808 100644 --- a/telegram/__init__.py +++ b/telegram/__init__.py @@ -43,7 +43,6 @@ from .forcereply import ForceReply from .error import TelegramError from .inputfile import InputFile from .file import File -from .nullhandler import NullHandler from .emoji import Emoji from .parsemode import ParseMode from .messageentity import MessageEntity @@ -101,14 +100,9 @@ __all__ = ['Audio', 'Bot', 'Chat', 'ChatMember', 'ChatAction', 'ChosenInlineResu 'InlineQueryResultVenue', 'InlineQueryResultVideo', 'InlineQueryResultVoice', 'InputContactMessageContent', 'InputFile', 'InputLocationMessageContent', 'InputMessageContent', 'InputTextMessageContent', 'InputVenueMessageContent', - 'KeyboardButton', 'Location', 'Message', 'MessageEntity', 'NullHandler', 'ParseMode', - 'PhotoSize', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup', 'ReplyMarkup', 'Sticker', - 'TelegramError', 'TelegramObject', 'Update', 'User', 'UserProfilePhotos', 'Venue', - 'Video', 'Voice', 'MAX_MESSAGE_LENGTH', 'MAX_CAPTION_LENGTH', 'SUPPORTED_WEBHOOK_PORTS', + 'KeyboardButton', 'Location', 'Message', 'MessageEntity', 'ParseMode', 'PhotoSize', + 'ReplyKeyboardHide', 'ReplyKeyboardMarkup', 'ReplyMarkup', 'Sticker', 'TelegramError', + 'TelegramObject', 'Update', 'User', 'UserProfilePhotos', 'Venue', 'Video', 'Voice', + 'MAX_MESSAGE_LENGTH', 'MAX_CAPTION_LENGTH', 'SUPPORTED_WEBHOOK_PORTS', 'MAX_FILESIZE_DOWNLOAD', 'MAX_FILESIZE_UPLOAD', 'MAX_MESSAGES_PER_SECOND_PER_CHAT', 'MAX_MESSAGES_PER_SECOND', 'MAX_MESSAGES_PER_MINUTE_PER_GROUP'] - -if version_info < (2, 7): - from warnings import warn - warn("python-telegram-bot will stop supporting Python 2.6 in a future release. " - "Please upgrade your Python version to at least Python 2.7!") diff --git a/telegram/bot.py b/telegram/bot.py index 2145bee79..21838e930 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -23,11 +23,11 @@ import functools import logging from telegram import (User, Message, Update, Chat, ChatMember, UserProfilePhotos, File, - ReplyMarkup, TelegramObject, NullHandler) + ReplyMarkup, TelegramObject) from telegram.error import InvalidToken from telegram.utils import request -logging.getLogger(__name__).addHandler(NullHandler()) +logging.getLogger(__name__).addHandler(logging.NullHandler()) class Bot(TelegramObject): diff --git a/telegram/contrib/botan.py b/telegram/contrib/botan.py index 8064a8ad8..97b7e72c0 100644 --- a/telegram/contrib/botan.py +++ b/telegram/contrib/botan.py @@ -1,11 +1,10 @@ import logging -from telegram import NullHandler from future.moves.urllib.parse import quote from future.moves.urllib.error import HTTPError, URLError from future.moves.urllib.request import urlopen, Request -logging.getLogger(__name__).addHandler(NullHandler()) +logging.getLogger(__name__).addHandler(logging.NullHandler()) class Botan(object): diff --git a/telegram/ext/dispatcher.py b/telegram/ext/dispatcher.py index 6469208aa..c6693e53a 100644 --- a/telegram/ext/dispatcher.py +++ b/telegram/ext/dispatcher.py @@ -26,13 +26,13 @@ from queue import Queue, Empty from future.builtins import range -from telegram import (TelegramError, NullHandler) +from telegram import TelegramError from telegram.utils import request from telegram.ext.handler import Handler from telegram.utils.deprecate import deprecate from telegram.utils.promise import Promise -logging.getLogger(__name__).addHandler(NullHandler()) +logging.getLogger(__name__).addHandler(logging.NullHandler()) ASYNC_QUEUE = Queue() ASYNC_THREADS = set() diff --git a/telegram/ext/updater.py b/telegram/ext/updater.py index 83c79e11b..29851c600 100644 --- a/telegram/ext/updater.py +++ b/telegram/ext/updater.py @@ -28,12 +28,12 @@ import subprocess from signal import signal, SIGINT, SIGTERM, SIGABRT from queue import Queue -from telegram import Bot, TelegramError, NullHandler +from telegram import Bot, TelegramError from telegram.ext import dispatcher, Dispatcher, JobQueue from telegram.error import Unauthorized, InvalidToken from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler) -logging.getLogger(__name__).addHandler(NullHandler()) +logging.getLogger(__name__).addHandler(logging.NullHandler()) class Updater(object): diff --git a/telegram/nullhandler.py b/telegram/nullhandler.py deleted file mode 100644 index 4783fa1c3..000000000 --- a/telegram/nullhandler.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -# -# A library that provides a Python interface to the Telegram Bot API -# Copyright (C) 2015-2016 -# Leandro Toledo de Souza -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser Public License for more details. -# -# You should have received a copy of the GNU Lesser Public License -# along with this program. If not, see [http://www.gnu.org/licenses/]. -"""This module contains a object that represents a logging NullHandler.""" - -import logging - - -class NullHandler(logging.Handler): - """This object represents a logging NullHandler.""" - - def emit(self, record): - """ - Args: - record (str): - """ - pass diff --git a/telegram/utils/webhookhandler.py b/telegram/utils/webhookhandler.py index 9d23aef9c..3abd9a2b3 100644 --- a/telegram/utils/webhookhandler.py +++ b/telegram/utils/webhookhandler.py @@ -1,6 +1,6 @@ import logging -from telegram import Update, NullHandler +from telegram import Update from future.utils import bytes_to_native_str from threading import Lock import json @@ -9,7 +9,7 @@ try: except ImportError: import http.server as BaseHTTPServer -logging.getLogger(__name__).addHandler(NullHandler()) +logging.getLogger(__name__).addHandler(logging.NullHandler()) class _InvalidPost(Exception): diff --git a/tests/test_bot.py b/tests/test_bot.py index 5b59b990f..152541948 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -23,14 +23,10 @@ import io import re from datetime import datetime import sys +import unittest from flaky import flaky -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest - sys.path.append('.') import telegram diff --git a/tests/test_choseninlineresult.py b/tests/test_choseninlineresult.py index 320c84672..ed757f26a 100644 --- a/tests/test_choseninlineresult.py +++ b/tests/test_choseninlineresult.py @@ -20,11 +20,7 @@ ChosenInlineResult""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_constants.py b/tests/test_constants.py index 2fa1ac77f..944b9e670 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -17,14 +17,10 @@ """Test the Telegram constants.""" import sys +import unittest from flaky import flaky -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest - sys.path.append('.') import telegram diff --git a/tests/test_conversationhandler.py b/tests/test_conversationhandler.py index 1cb9f8c7c..d78d72c84 100644 --- a/tests/test_conversationhandler.py +++ b/tests/test_conversationhandler.py @@ -22,13 +22,9 @@ This module contains a object that represents Tests for ConversationHandler """ import logging import sys +import unittest from time import sleep -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest - try: # python2 from urllib2 import urlopen, Request, HTTPError diff --git a/tests/test_inlinekeyboardbutton.py b/tests/test_inlinekeyboardbutton.py index f28f9682b..2b6b8c185 100644 --- a/tests/test_inlinekeyboardbutton.py +++ b/tests/test_inlinekeyboardbutton.py @@ -20,11 +20,7 @@ """This module contains a object that represents Tests for Telegram InlineKeyboardButton""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequery.py b/tests/test_inlinequery.py index 98148b596..47560d03b 100644 --- a/tests/test_inlinequery.py +++ b/tests/test_inlinequery.py @@ -20,11 +20,7 @@ InlineQuery""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultarticle.py b/tests/test_inlinequeryresultarticle.py index 402f6958c..9e0fa3972 100644 --- a/tests/test_inlinequeryresultarticle.py +++ b/tests/test_inlinequeryresultarticle.py @@ -20,11 +20,7 @@ InlineQueryResultArticle""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultaudio.py b/tests/test_inlinequeryresultaudio.py index ee850f0a7..3d5ab8cf2 100644 --- a/tests/test_inlinequeryresultaudio.py +++ b/tests/test_inlinequeryresultaudio.py @@ -20,11 +20,7 @@ InlineQueryResultAudio""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcachedaudio.py b/tests/test_inlinequeryresultcachedaudio.py index 072d1ed85..cb3787e49 100644 --- a/tests/test_inlinequeryresultcachedaudio.py +++ b/tests/test_inlinequeryresultcachedaudio.py @@ -20,11 +20,7 @@ InlineQueryResultCachedAudio""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcacheddocument.py b/tests/test_inlinequeryresultcacheddocument.py index 715589730..144f4d846 100644 --- a/tests/test_inlinequeryresultcacheddocument.py +++ b/tests/test_inlinequeryresultcacheddocument.py @@ -20,11 +20,7 @@ InlineQueryResultCachedDocument""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcachedgif.py b/tests/test_inlinequeryresultcachedgif.py index 01b7ebc10..df3556b19 100644 --- a/tests/test_inlinequeryresultcachedgif.py +++ b/tests/test_inlinequeryresultcachedgif.py @@ -20,11 +20,7 @@ InlineQueryResultCachedGif""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcachedmpeg4gif.py b/tests/test_inlinequeryresultcachedmpeg4gif.py index 90abdf232..609795b4c 100644 --- a/tests/test_inlinequeryresultcachedmpeg4gif.py +++ b/tests/test_inlinequeryresultcachedmpeg4gif.py @@ -20,11 +20,7 @@ InlineQueryResultCachedMpeg4Gif""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcachedphoto.py b/tests/test_inlinequeryresultcachedphoto.py index 51e959bf3..67beb03c9 100644 --- a/tests/test_inlinequeryresultcachedphoto.py +++ b/tests/test_inlinequeryresultcachedphoto.py @@ -20,11 +20,7 @@ InlineQueryResultCachedPhoto""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcachedsticker.py b/tests/test_inlinequeryresultcachedsticker.py index 7e486740d..b3d1a99f7 100644 --- a/tests/test_inlinequeryresultcachedsticker.py +++ b/tests/test_inlinequeryresultcachedsticker.py @@ -20,11 +20,7 @@ InlineQueryResultCachedSticker""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcachedvideo.py b/tests/test_inlinequeryresultcachedvideo.py index 450dbad76..84e4d9687 100644 --- a/tests/test_inlinequeryresultcachedvideo.py +++ b/tests/test_inlinequeryresultcachedvideo.py @@ -20,11 +20,7 @@ InlineQueryResultCachedVideo""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcachedvoice.py b/tests/test_inlinequeryresultcachedvoice.py index 50fed9b06..5297f1d5e 100644 --- a/tests/test_inlinequeryresultcachedvoice.py +++ b/tests/test_inlinequeryresultcachedvoice.py @@ -20,11 +20,7 @@ InlineQueryResultCachedVoice""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultcontact.py b/tests/test_inlinequeryresultcontact.py index d9b43ed84..f36fc5cbe 100644 --- a/tests/test_inlinequeryresultcontact.py +++ b/tests/test_inlinequeryresultcontact.py @@ -20,11 +20,7 @@ InlineQueryResultContact""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultdocument.py b/tests/test_inlinequeryresultdocument.py index cff1b0a9f..91b7caf42 100644 --- a/tests/test_inlinequeryresultdocument.py +++ b/tests/test_inlinequeryresultdocument.py @@ -20,11 +20,7 @@ InlineQueryResultDocument""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultgif.py b/tests/test_inlinequeryresultgif.py index 05694ff89..d4f8d8861 100644 --- a/tests/test_inlinequeryresultgif.py +++ b/tests/test_inlinequeryresultgif.py @@ -20,11 +20,7 @@ InlineQueryResultGif""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultlocation.py b/tests/test_inlinequeryresultlocation.py index 55031b02e..903bb4545 100644 --- a/tests/test_inlinequeryresultlocation.py +++ b/tests/test_inlinequeryresultlocation.py @@ -20,11 +20,7 @@ InlineQueryResultLocation""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultmpeg4gif.py b/tests/test_inlinequeryresultmpeg4gif.py index 572a12782..751017e9c 100644 --- a/tests/test_inlinequeryresultmpeg4gif.py +++ b/tests/test_inlinequeryresultmpeg4gif.py @@ -20,11 +20,7 @@ InlineQueryResultMpeg4Gif""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultphoto.py b/tests/test_inlinequeryresultphoto.py index fd1176109..76cf22ad4 100644 --- a/tests/test_inlinequeryresultphoto.py +++ b/tests/test_inlinequeryresultphoto.py @@ -20,11 +20,7 @@ InlineQueryResultPhoto""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultvenue.py b/tests/test_inlinequeryresultvenue.py index c0eaefd92..73af4c4bb 100644 --- a/tests/test_inlinequeryresultvenue.py +++ b/tests/test_inlinequeryresultvenue.py @@ -20,11 +20,7 @@ InlineQueryResultVenue""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultvideo.py b/tests/test_inlinequeryresultvideo.py index 60c4ea0da..5d33182a8 100644 --- a/tests/test_inlinequeryresultvideo.py +++ b/tests/test_inlinequeryresultvideo.py @@ -20,11 +20,7 @@ InlineQueryResultVideo""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inlinequeryresultvoice.py b/tests/test_inlinequeryresultvoice.py index b39bd54cb..4a7eb80ef 100644 --- a/tests/test_inlinequeryresultvoice.py +++ b/tests/test_inlinequeryresultvoice.py @@ -20,11 +20,7 @@ InlineQueryResultVoice""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inputcontactmessagecontent.py b/tests/test_inputcontactmessagecontent.py index a3308eea6..41ee007bf 100644 --- a/tests/test_inputcontactmessagecontent.py +++ b/tests/test_inputcontactmessagecontent.py @@ -20,11 +20,7 @@ InputContactMessageContent""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inputlocationmessagecontent.py b/tests/test_inputlocationmessagecontent.py index 11d0e46c9..876fe8d0a 100644 --- a/tests/test_inputlocationmessagecontent.py +++ b/tests/test_inputlocationmessagecontent.py @@ -20,11 +20,7 @@ InputLocationMessageContent""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inputmessagecontent.py b/tests/test_inputmessagecontent.py index af91261ee..ad9c08718 100644 --- a/tests/test_inputmessagecontent.py +++ b/tests/test_inputmessagecontent.py @@ -20,11 +20,7 @@ InputMessageContent""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inputtextmessagecontent.py b/tests/test_inputtextmessagecontent.py index 589186e3d..7aa1fe873 100644 --- a/tests/test_inputtextmessagecontent.py +++ b/tests/test_inputtextmessagecontent.py @@ -20,11 +20,7 @@ InputTextMessageContent""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_inputvenuemessagecontent.py b/tests/test_inputvenuemessagecontent.py index e2f4225cb..a1ce7311b 100644 --- a/tests/test_inputvenuemessagecontent.py +++ b/tests/test_inputvenuemessagecontent.py @@ -20,11 +20,7 @@ InputVenueMessageContent""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_jobqueue.py b/tests/test_jobqueue.py index bdfb602fb..be481b937 100644 --- a/tests/test_jobqueue.py +++ b/tests/test_jobqueue.py @@ -22,13 +22,9 @@ This module contains a object that represents Tests for JobQueue """ import logging import sys +import unittest from time import sleep -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest - sys.path.append('.') from telegram.utils.request import stop_con_pool diff --git a/tests/test_keyboardbutton.py b/tests/test_keyboardbutton.py index 313dccaea..9dab40120 100644 --- a/tests/test_keyboardbutton.py +++ b/tests/test_keyboardbutton.py @@ -21,11 +21,7 @@ KeyboardButton""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_messageentity.py b/tests/test_messageentity.py index 2036c68d4..7f154c144 100644 --- a/tests/test_messageentity.py +++ b/tests/test_messageentity.py @@ -20,11 +20,7 @@ MessageEntity""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_replymarkup.py b/tests/test_replymarkup.py index b24b886ea..4e4e3715a 100644 --- a/tests/test_replymarkup.py +++ b/tests/test_replymarkup.py @@ -20,11 +20,7 @@ ReplyMarkup""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.') diff --git a/tests/test_updater.py b/tests/test_updater.py index 9a6692f0f..18efebf6c 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -26,17 +26,13 @@ import signal import sys import os import re +import unittest from datetime import datetime from time import sleep from random import randrange from future.builtins import bytes -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest - try: # python2 from urllib2 import urlopen, Request, HTTPError diff --git a/tests/test_venue.py b/tests/test_venue.py index 3ea9a83db..853ad286f 100644 --- a/tests/test_venue.py +++ b/tests/test_venue.py @@ -19,11 +19,7 @@ """This module contains a object that represents Tests for Telegram Venue""" import sys - -if sys.version_info[0:2] == (2, 6): - import unittest2 as unittest -else: - import unittest +import unittest sys.path.append('.')