diff --git a/dev-requirements.txt b/dev-requirements.txt index a08abb2..5727d1e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,4 @@ -coverage==3.7.1 +coverage nose nose-cov -testtools \ No newline at end of file +testtools diff --git a/packer.py b/packer.py index a50758f..33cc535 100644 --- a/packer.py +++ b/packer.py @@ -41,9 +41,8 @@ def __init__(self, packerfile, exc=None, only=None, vars=None, self.packer = sh.Command(exec_path) self.packer = self.packer.bake(**kwargs) - def build( - self, parallel=True, debug=False, force=False, - machine_readable=False): + def build(self, parallel=True, debug=False, force=False, + machine_readable=False): """Executes a `packer build` :param bool parallel: Run builders in parallel @@ -74,8 +73,8 @@ def fix(self, to_file=None): result = self.packer_cmd() if to_file: with open(to_file, 'w') as f: - f.write(result.stdout) - result.fixed = json.loads(result.stdout) + f.write(result.stdout.decode()) + result.fixed = json.loads(result.stdout.decode()) return result def inspect(self, mrf=True): @@ -115,7 +114,8 @@ def inspect(self, mrf=True): result = self.packer_cmd() if mrf: - result.parsed_output = self._parse_inspection_output(result.stdout) + result.parsed_output = self._parse_inspection_output( + result.stdout.decode()) else: result.parsed_output = None return result diff --git a/setup.py b/setup.py index 161d075..0aa8dd8 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def read(*parts): description='A Python interface for Hashicorp\'s Packer', long_description=read('README.rst'), py_modules=['packer'], - install_requires=["sh==1.11"], + install_requires=["sh"], classifiers=[ 'Programming Language :: Python', 'Natural Language :: English', diff --git a/tests/resources/simple-test.json b/tests/resources/simple-test.json new file mode 100644 index 0000000..58e8623 --- /dev/null +++ b/tests/resources/simple-test.json @@ -0,0 +1,10 @@ +{ + "builders": [ + { + "type": "null", + "ssh_host": "127.0.0.1", + "ssh_username": "root", + "ssh_password": "password" + } + ] +} diff --git a/tests/test_packer.py b/tests/test_packer.py index 424e01d..1ec037b 100644 --- a/tests/test_packer.py +++ b/tests/test_packer.py @@ -5,7 +5,7 @@ PACKER_PATH = '/usr/bin/packer' TEST_RESOURCES_DIR = 'tests/resources' -TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'packerfile.json') +TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'simple-test.json') TEST_BAD_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'badpackerfile.json') diff --git a/tox.ini b/tox.ini index 0ed516a..307795b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,8 @@ # content of: tox.ini , put in same dir as setup.py [tox] -envlist=flake8,py27,py26 +envlist=flake8,py27,py26,py35 -[testenv:py26] -deps = - -rdev-requirements.txt -commands=nosetests --with-cov --cov-report term-missing --cov packer tests -v - -[testenv:py27] +[testenv] deps = -rdev-requirements.txt commands=nosetests --with-cov --cov-report term-missing --cov packer tests -v