diff --git a/.travis.yml b/.travis.yml index 748ef28d..fbaefd1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,8 @@ addons: - pandoc language: python python: -- 2.7 -- 3.4 -- 3.5 - 3.6 +- 3.7 matrix: include: - python: 3.6 diff --git a/nornir/core/__init__.py b/nornir/core/__init__.py index 668cffb1..6905fb76 100644 --- a/nornir/core/__init__.py +++ b/nornir/core/__init__.py @@ -1,6 +1,5 @@ import logging import logging.config -import sys from multiprocessing.dummy import Pool from nornir.core.configuration import Config @@ -8,36 +7,6 @@ from nornir.plugins.tasks import connections -if sys.version_info.major == 2: - import copy_reg - import types - - # multithreading requires objects passed around to be pickable - # following methods allow py2 to know how to pickle methods - - def _pickle_method(method): - func_name = method.im_func.__name__ - obj = method.im_self - cls = method.im_class - return _unpickle_method, (func_name, obj, cls) - - def _unpickle_method(func_name, obj, cls): - for cls_tmp in cls.mro(): - try: - func = cls_tmp.__dict__[func_name] - except KeyError: - pass - else: - break - - else: - raise ValueError("Method ({}) not found for obj: {}".format(func_name, obj)) - - return func.__get__(obj, cls_tmp) - - copy_reg.pickle(types.MethodType, _pickle_method, _unpickle_method) - - class Data(object): """ This class is just a placeholder to share data amongst different diff --git a/setup.py b/setup.py index 44c7b2ec..53564573 100644 --- a/setup.py +++ b/setup.py @@ -27,11 +27,6 @@ test_suite="tests", platforms="any", classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], ) diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stderr b/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stderr deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stdout b/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stdout deleted file mode 100644 index 94bdebb1..00000000 --- a/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stdout +++ /dev/null @@ -1,6 +0,0 @@ -vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ----- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Nornir ----- load_data ** changed : False ---------------------------------------------- INFO -{ 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} -^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stderr b/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stderr deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stdout b/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stdout deleted file mode 100644 index be49c4a9..00000000 --- a/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stdout +++ /dev/null @@ -1,2 +0,0 @@ ----- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Nornir diff --git a/tests/plugins/functions/text/output_data/basic_inventory_python27.stderr b/tests/plugins/functions/text/output_data/basic_inventory_python27.stderr deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/plugins/functions/text/output_data/basic_inventory_python27.stdout b/tests/plugins/functions/text/output_data/basic_inventory_python27.stdout deleted file mode 100644 index e53e05bf..00000000 --- a/tests/plugins/functions/text/output_data/basic_inventory_python27.stdout +++ /dev/null @@ -1,17 +0,0 @@ -echo_task*********************************************************************** -* dev1.group_1 ** changed : False ********************************************** -vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Nornir -^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev2.group_1 ** changed : False ********************************************** -vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Nornir -^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev3.group_2 ** changed : False ********************************************** -vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Nornir -^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev4.group_2 ** changed : False ********************************************** -vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Nornir -^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/basic_single_python27.stderr b/tests/plugins/functions/text/output_data/basic_single_python27.stderr deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/plugins/functions/text/output_data/basic_single_python27.stdout b/tests/plugins/functions/text/output_data/basic_single_python27.stdout deleted file mode 100644 index 8cbbe534..00000000 --- a/tests/plugins/functions/text/output_data/basic_single_python27.stdout +++ /dev/null @@ -1,5 +0,0 @@ -echo_task*********************************************************************** -* dev1.group_1 ** changed : False ********************************************** -vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Nornir -^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/changed_host_python27.stderr b/tests/plugins/functions/text/output_data/changed_host_python27.stderr deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/plugins/functions/text/output_data/changed_host_python27.stdout b/tests/plugins/functions/text/output_data/changed_host_python27.stdout deleted file mode 100644 index 7c043e9a..00000000 --- a/tests/plugins/functions/text/output_data/changed_host_python27.stdout +++ /dev/null @@ -1,15 +0,0 @@ -read_data*********************************************************************** -* dev1.group_1 ** changed : True *********************************************** -vvvv read_data ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WARNING ----- echo_task ** changed : False ---------------------------------------------- CRITICAL -Hello from CRITICAL ----- parse_data ** changed : True ---------------------------------------------- WARNING -[1, 2, 3] -^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev2.group_1 ** changed : False ********************************************** -vvvv read_data ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WARNING ----- echo_task ** changed : False ---------------------------------------------- CRITICAL -Hello from CRITICAL ----- parse_data ** changed : False --------------------------------------------- WARNING -[4, 5, 6] -^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/failed_with_severity_python27.stderr b/tests/plugins/functions/text/output_data/failed_with_severity_python27.stderr deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/plugins/functions/text/output_data/failed_with_severity_python27.stdout b/tests/plugins/functions/text/output_data/failed_with_severity_python27.stdout deleted file mode 100644 index a80685c3..00000000 --- a/tests/plugins/functions/text/output_data/failed_with_severity_python27.stdout +++ /dev/null @@ -1,21 +0,0 @@ -read_data*********************************************************************** -* dev1.group_1 ** changed : True *********************************************** ----- echo_task ** changed : False ---------------------------------------------- CRITICAL -Hello from CRITICAL -^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev2.group_1 ** changed : False ********************************************** ----- echo_task ** changed : False ---------------------------------------------- CRITICAL -Hello from CRITICAL -^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev3.group_2 ** changed : False ********************************************** ----- echo_task ** changed : False ---------------------------------------------- CRITICAL -Hello from CRITICAL -^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev4.group_2 ** changed : False ********************************************** -vvvv read_data ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR -NornirSubTaskError() ----- echo_task ** changed : False ---------------------------------------------- CRITICAL -Hello from CRITICAL ----- parse_data ** changed : False --------------------------------------------- ERROR -Exception('Unknown Error -> Contact your system administrator',) -^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/multiple_tasks_python27.stderr b/tests/plugins/functions/text/output_data/multiple_tasks_python27.stderr deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/plugins/functions/text/output_data/multiple_tasks_python27.stdout b/tests/plugins/functions/text/output_data/multiple_tasks_python27.stdout deleted file mode 100644 index 5c1105d5..00000000 --- a/tests/plugins/functions/text/output_data/multiple_tasks_python27.stdout +++ /dev/null @@ -1,30 +0,0 @@ -**** Behold the data! ********************************************************** -data_with_greeting************************************************************** -* dev1.group_1 ** changed : False ********************************************** -vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ----- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Nornir ----- load_data ** changed : False ---------------------------------------------- INFO -{ 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} -^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev2.group_1 ** changed : False ********************************************** -vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ----- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Nornir ----- load_data ** changed : False ---------------------------------------------- INFO -{ 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} -^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev3.group_2 ** changed : False ********************************************** -vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ----- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Nornir ----- load_data ** changed : False ---------------------------------------------- INFO -{ 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} -^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* dev4.group_2 ** changed : False ********************************************** -vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ----- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Nornir ----- load_data ** changed : False ---------------------------------------------- INFO -{ 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} -^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/tasks/data/test_load_json.py b/tests/plugins/tasks/data/test_load_json.py index 686952fd..95d8d9e3 100644 --- a/tests/plugins/tasks/data/test_load_json.py +++ b/tests/plugins/tasks/data/test_load_json.py @@ -1,5 +1,4 @@ import os -import sys from nornir.plugins.tasks import data @@ -30,15 +29,10 @@ def test_load_json_error_broken_file(self, nornir): def test_load_json_error_missing_file(self, nornir): test_file = "{}/missing.json".format(data_dir) - if sys.version_info.major == 2: - not_found = IOError - else: - not_found = FileNotFoundError # noqa - results = nornir.run(data.load_json, file=test_file) processed = False for result in results.values(): processed = True - assert isinstance(result.exception, not_found) + assert isinstance(result.exception, FileNotFoundError) assert processed nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/data/test_load_yaml.py b/tests/plugins/tasks/data/test_load_yaml.py index de9eba05..d11b473b 100644 --- a/tests/plugins/tasks/data/test_load_yaml.py +++ b/tests/plugins/tasks/data/test_load_yaml.py @@ -1,5 +1,4 @@ import os -import sys from nornir.plugins.tasks import data @@ -34,16 +33,10 @@ def test_load_yaml_error_broken_file(self, nornir): def test_load_yaml_error_missing_file(self, nornir): test_file = "{}/missing.yaml".format(data_dir) - - if sys.version_info.major == 2: - not_found = IOError - else: - not_found = FileNotFoundError # noqa - results = nornir.run(data.load_yaml, file=test_file) processed = False for result in results.values(): processed = True - assert isinstance(result.exception, not_found) + assert isinstance(result.exception, FileNotFoundError) assert processed nornir.data.reset_failed_hosts() diff --git a/tests/wrapper.py b/tests/wrapper.py index 66b83da1..2378485e 100644 --- a/tests/wrapper.py +++ b/tests/wrapper.py @@ -1,10 +1,7 @@ import sys -from decorator import decorator +from io import StringIO -if sys.version_info.major == 2: - from StringIO import StringIO -else: - from io import StringIO +from decorator import decorator def wrap_cli_test(output, save_output=False): @@ -33,8 +30,6 @@ def run_test(func, *args, **kwargs): sys.stderr = backup_stderr output_file = output - if sys.version_info.major == 2: - output_file += "_python27" if save_output: with open("{}.stdout".format(output_file), "w+") as f: diff --git a/tox.ini b/tox.ini index b26595fb..0249d564 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36 +envlist = py36,py37 [testenv] deps =