Skip to content

Commit

Permalink
Merge aabb352 into af948f2
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop committed Jul 9, 2018
2 parents af948f2 + aabb352 commit 4bdbba8
Show file tree
Hide file tree
Showing 21 changed files with 7 additions and 159 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ addons:
- pandoc
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7
matrix:
include:
- python: 3.6
Expand Down
31 changes: 0 additions & 31 deletions nornir/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
import logging
import logging.config
import sys
from multiprocessing.dummy import Pool

from nornir.core.configuration import Config
from nornir.core.task import AggregatedResult, Task
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
Expand Down
7 changes: 1 addition & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
)
Empty file.

This file was deleted.

Empty file.

This file was deleted.

Empty file.

This file was deleted.

Empty file.

This file was deleted.

Empty file.

This file was deleted.

Empty file.

This file was deleted.

Empty file.

This file was deleted.

8 changes: 1 addition & 7 deletions tests/plugins/tasks/data/test_load_json.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys

from nornir.plugins.tasks import data

Expand Down Expand Up @@ -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()
9 changes: 1 addition & 8 deletions tests/plugins/tasks/data/test_load_yaml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys


from nornir.plugins.tasks import data
Expand Down Expand Up @@ -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()
9 changes: 2 additions & 7 deletions tests/wrapper.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35,py36
envlist = py36,py37

[testenv]
deps =
Expand Down

0 comments on commit 4bdbba8

Please sign in to comment.