From cbd8f8236a7bfc36fc8747cd1bdb96b4a8437ee4 Mon Sep 17 00:00:00 2001 From: Cyril Jouve Date: Thu, 31 Jan 2019 13:47:56 +0100 Subject: [PATCH] Remove Python 2.6 code that's now obsolete. Fixes #3935 --- docs/en_US/release_notes_4_2.rst | 3 +- pkg/pip/setup_pip.py | 20 ------------ requirements.txt | 31 +++++-------------- .../tools/backup/tests/test_batch_process.py | 5 +-- .../tests/test_batch_process_maintenance.py | 5 +-- .../tools/restore/tests/test_batch_process.py | 5 +-- web/pgadmin/utils/route.py | 5 +-- .../utils/sqlautocomplete/autocomplete.py | 6 +--- web/regression/requirements.txt | 12 +------ web/regression/runtests.py | 19 +++++------- 10 files changed, 24 insertions(+), 87 deletions(-) diff --git a/docs/en_US/release_notes_4_2.rst b/docs/en_US/release_notes_4_2.rst index 226b2e0ec..2d9a577b9 100644 --- a/docs/en_US/release_notes_4_2.rst +++ b/docs/en_US/release_notes_4_2.rst @@ -46,4 +46,5 @@ Bug fixes | `Bug #3916 `_ - Correct schema should be displayed in Materialized View dialog. | `Bug #3927 `_ - Fixed debugger issue for procedure inside package for EPAS servers. | `Bug #3929 `_ - Fix alignment of help messages in properties panels. -| `Bug #3935 `_ - Ensure that grant wizard should list down functions for EPAS server running with no-redwood-compat mode. \ No newline at end of file +| `Bug #3935 `_ - Ensure that grant wizard should list down functions for EPAS server running with no-redwood-compat mode. +| `Bug #3954 `_ - Remove Python 2.6 code that's now obsolete. \ No newline at end of file diff --git a/pkg/pip/setup_pip.py b/pkg/pip/setup_pip.py index a69b6f6e1..f1bb4af45 100644 --- a/pkg/pip/setup_pip.py +++ b/pkg/pip/setup_pip.py @@ -66,7 +66,6 @@ setup( 'Development Status :: 5 - Production/Stable', # Supported programming languages - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', @@ -85,28 +84,9 @@ setup( install_requires=required, extras_require={ - # ... - ":python_version<'2.7'": [ - "psycopg2==2.7.3.2", - "Flask-Script==2.0.5", - "ordereddict", - "python-dateutil==2.5.0", - "SQLAlchemy==1.0.14", - "Flask-Security==1.7.5", - "Flask-BabelEx==0.9.3" - ], ":python_version<='2.7'": [ "importlib==1.0.3" ], - ":python_version>='2.7'": [ - "psycopg2>=2.7.4", - "python-dateutil>=2.7.1", - "htmlmin==0.1.12", - "Flask-HTMLmin==1.3.2", - "SQLAlchemy>=1.2.5", - "Flask-Security>=3.0.0", - "sshtunnel>=0.1.3" - ] }, # Specify data files to be included. diff --git a/requirements.txt b/requirements.txt index 92eae7dd1..e4232191f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,30 +29,15 @@ sqlparse==0.2.4 WTForms==2.1 Flask-Paranoid==0.2.0 psutil==5.4.7 - -################################################################ -# Modules specifically requires for Python2.7 or greater version -################################################################ -psycopg2>=2.7.4; python_version >= '2.7' -python-dateutil>=2.7.1; python_version >= '2.7' -htmlmin==0.1.12; python_version >= '2.7' -Flask-HTMLmin==1.3.2; python_version >= '2.7' -SQLAlchemy>=1.2.5; python_version >= '2.7' -Flask-Security>=3.0.0; python_version >= '2.7' -sshtunnel>=0.1.3; python_version >= '2.7' +psycopg2>=2.7.4 +python-dateutil>=2.7.1 +htmlmin==0.1.12 +Flask-HTMLmin==1.3.2 +SQLAlchemy>=1.2.5 +Flask-Security>=3.0.0 +sshtunnel>=0.1.3 ############################################################### -# Modules specifically required for Python2.7 or lesser version +# Modules specifically required for Python2.7 ############################################################### importlib==1.0.3; python_version <= '2.7' - -############################################################### -# Modules required for Python2.6 -############################################################### -psycopg2==2.7.3.2; python_version < '2.7' -Flask-Script==2.0.5; python_version < '2.7' -ordereddict; python_version < '2.7' -python-dateutil==2.5.0; python_version < '2.7' -SQLAlchemy==1.0.14; python_version < '2.7' -Flask-Security==1.7.5; python_version < '2.7' -Flask-BabelEx==0.9.3; python_version < '2.7' diff --git a/web/pgadmin/tools/backup/tests/test_batch_process.py b/web/pgadmin/tools/backup/tests/test_batch_process.py index 8a51bce65..15fb94481 100644 --- a/web/pgadmin/tools/backup/tests/test_batch_process.py +++ b/web/pgadmin/tools/backup/tests/test_batch_process.py @@ -119,10 +119,7 @@ class BatchProcessTest(BaseTestGenerator): current_app_mock.PGADMIN_RUNTIME = False def db_session_add_mock(j): - if sys.version_info < (2, 7): - cmd_obj = loads(str(j.desc)) - else: - cmd_obj = loads(j.desc) + cmd_obj = loads(j.desc) self.assertTrue(isinstance(cmd_obj, IProcessDesc)) self.assertEqual(cmd_obj.backup_type, self.class_params['type']) self.assertEqual(cmd_obj.bfile, self.class_params['bfile']) diff --git a/web/pgadmin/tools/maintenance/tests/test_batch_process_maintenance.py b/web/pgadmin/tools/maintenance/tests/test_batch_process_maintenance.py index 8a238e7c0..242698a23 100644 --- a/web/pgadmin/tools/maintenance/tests/test_batch_process_maintenance.py +++ b/web/pgadmin/tools/maintenance/tests/test_batch_process_maintenance.py @@ -73,10 +73,7 @@ class BatchProcessTest(BaseTestGenerator): self.port = port def db_session_add_mock(j): - if sys.version_info < (2, 7): - cmd_obj = loads(str(j.desc)) - else: - cmd_obj = loads(j.desc) + cmd_obj = loads(j.desc) self.assertTrue(isinstance(cmd_obj, IProcessDesc)) self.assertEqual(cmd_obj.query, self.class_params['cmd']) self.assertEqual(cmd_obj.message, self.expected_msg) diff --git a/web/pgadmin/tools/restore/tests/test_batch_process.py b/web/pgadmin/tools/restore/tests/test_batch_process.py index 674eca079..39836133f 100644 --- a/web/pgadmin/tools/restore/tests/test_batch_process.py +++ b/web/pgadmin/tools/restore/tests/test_batch_process.py @@ -64,10 +64,7 @@ class BatchProcessTest(BaseTestGenerator): current_app_mock.PGADMIN_RUNTIME = False def db_session_add_mock(j): - if sys.version_info < (2, 7): - cmd_obj = loads(str(j.desc)) - else: - cmd_obj = loads(j.desc) + cmd_obj = loads(j.desc) self.assertTrue(isinstance(cmd_obj, IProcessDesc)) self.assertEqual(cmd_obj.bfile, self.class_params['bfile']) self.assertEqual(cmd_obj.cmd, diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py index e45e06b71..e67f01958 100644 --- a/web/pgadmin/utils/route.py +++ b/web/pgadmin/utils/route.py @@ -16,10 +16,7 @@ import six from werkzeug.utils import find_modules from pgadmin.utils import server_utils -if sys.version_info < (2, 7): - import unittest2 as unittest -else: - import unittest +import unittest class TestsGeneratorRegistry(ABCMeta): diff --git a/web/pgadmin/utils/sqlautocomplete/autocomplete.py b/web/pgadmin/utils/sqlautocomplete/autocomplete.py index 4ad928c7d..da97e6078 100644 --- a/web/pgadmin/utils/sqlautocomplete/autocomplete.py +++ b/web/pgadmin/utils/sqlautocomplete/autocomplete.py @@ -14,11 +14,7 @@ import operator import sys from itertools import count, repeat, chain from .completion import Completion -from collections import namedtuple, defaultdict -if sys.version_info < (2, 7): - from ordereddict import OrderedDict -else: - from collections import OrderedDict +from collections import namedtuple, defaultdict, OrderedDict from .sqlcompletion import ( FromClauseItem, suggest_type, Database, Schema, Table, diff --git a/web/regression/requirements.txt b/web/regression/requirements.txt index 25bbe9899..77044c05e 100644 --- a/web/regression/requirements.txt +++ b/web/regression/requirements.txt @@ -11,17 +11,7 @@ pyperclip~=1.6.0 testscenarios==0.5.0 testtools==2.3.0 traceback2==1.4.0 -unittest2==1.1.0 - -################################################################ -# Modules specifically requires for Python2.7 or greater version -################################################################ -selenium==3.11.0; python_version >= '2.7' - -############################################################### -# Modules required for Python2.6 -############################################################### -selenium==3.3.3; python_version < '2.7' +selenium==3.11.0 ############################################################### # Modules specifically required for Python3.3 or lesser version diff --git a/web/regression/runtests.py b/web/regression/runtests.py index b023703d9..48d3749f3 100644 --- a/web/regression/runtests.py +++ b/web/regression/runtests.py @@ -25,10 +25,7 @@ from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.desired_capabilities import DesiredCapabilities -if sys.version_info < (2, 7): - import unittest2 as unit_test -else: - import unittest as unit_test +import unittest if sys.version_info[0] >= 3: import builtins @@ -119,9 +116,9 @@ app.PGADMIN_RUNTIME = True if config.SERVER_MODE is True: app.PGADMIN_RUNTIME = False -setattr(unit_test.result.TestResult, "passed", []) +setattr(unittest.result.TestResult, "passed", []) -unit_test.runner.TextTestResult.addSuccess = test_utils.add_success +unittest.runner.TextTestResult.addSuccess = test_utils.add_success # Override apply_scenario method as we need custom test description/name scenarios.apply_scenario = test_utils.apply_scenario @@ -143,7 +140,7 @@ def get_suite(module_list, test_server, test_app_client, server_information, :rtype: TestSuite """ modules = [] - pgadmin_suite = unit_test.TestSuite() + pgadmin_suite = unittest.TestSuite() # Get the each test module and add into list for key, klass in module_list: @@ -423,9 +420,9 @@ if __name__ == '__main__': server, test_client, server_information, test_db_name) - tests = unit_test.TextTestRunner(stream=sys.stderr, - descriptions=True, - verbosity=2).run(suite) + tests = unittest.TextTestRunner(stream=sys.stderr, + descriptions=True, + verbosity=2).run(suite) ran_tests, failed_cases, skipped_cases, passed_cases = \ get_tests_result(tests) @@ -434,7 +431,7 @@ if __name__ == '__main__': # Set empty list for 'passed' parameter for each testRun. # So that it will not append same test case name - unit_test.result.TestResult.passed = [] + unittest.result.TestResult.passed = [] if len(failed_cases) > 0: failure = True