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)

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)

--- 
+++ 
@@ -1,6 +1,6 @@
 from __future__ import absolute_import, division, print_function
 
-from subprocess import check_output
+import subprocess
 import os
 
 def test_function():
@@ -11,7 +11,8 @@
     echo '{"hello":"world"}' | jsonf go
     """
 
-    out = check_output(['bash', '-c', setup])
+    p1 = subprocess.Popen(['bash', '-c', setup], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+    out, err = p1.communicate()
 
     hello = """
     #!/bin/bash
@@ -20,6 +21,8 @@
     echo '{"hello":"world"}' | jsonf go
     """
     
-    out = check_output(['bash', '-c', hello])
+    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 out)
+    assert('{\n  "hello" : "world"\n}\n' in result)
Revert "fix test by switching to check_output"

This reverts commit 6cfd9d01d68c2f7ff4a8bba3351ee618e770d315.
