from __future__ import absolute_import, division, print_function

from subprocess import check_output
import os

def test_function():
    setup = """
    #!/bin/bash

    huckle install https://hcli.io/hcli/cli/jsonf?command=jsonf
    echo '{"hello":"world"}' | jsonf go
    """

    out = check_output(['bash', '-c', setup])

    hello = """
    #!/bin/bash

    export PATH=$PATH:~/.huckle/bin
    echo '{"hello":"world"}' | jsonf go
    """
    
    out = check_output(['bash', '-c', hello])

    assert('{\n  "hello" : "world"\n}\n' in out)

from __future__ import absolute_import, division, print_function

import subprocess
import os

def test_function():
    setup = """
    #!/bin/bash

    huckle install https://hcli.io/hcli/cli/jsonf?command=jsonf
    echo '{"hello":"world"}' | jsonf go
    """

    p1 = subprocess.Popen(['bash', '-c', setup], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    out, err = p1.communicate()

    hello = """
    #!/bin/bash

    export PATH=$PATH:~/.huckle/bin
    echo '{"hello":"world"}' | jsonf go
    """
    
    p2 = subprocess.Popen(['bash', '-c', hello], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    out, err = p2.communicate()
    result = out.decode('utf-8')

    assert('{\n  "hello" : "world"\n}\n' in result)

Revert "fix test by switching to check_output"