from nose.tools import *
from exercises import ex12

def test_histogram():
    '''
    Test our histogram output is correct
    '''

    test_histogram = ex12.histogram([1, 2, 3])
#    assert_equal(test_histogram, '*\n**\n***\n')


from nose.tools import *
from exercises import ex12
try:
    from io import StringIO
except:
    from StringIO import StringIO
import sys

def test_histogram():
    '''
    Test our histogram output is correct
    '''

    std_out = sys.stdout
    result = StringIO()
    sys.stdout = result

    test_histogram = ex12.histogram([1, 2, 3])
    sys.stdout = std_out

    result_string = result.getvalue()

    assert_equal(result_string, '*\n**\n***\n')


Update ex12 test so it actually reads output.
Update ex12 test so it actually reads output.

  from nose.tools import *
  from exercises import ex12
+ try:
+     from io import StringIO
+ except:
+     from StringIO import StringIO
+ import sys
  
  def test_histogram():
      '''
      Test our histogram output is correct
      '''
  
+     std_out = sys.stdout
+     result = StringIO()
+     sys.stdout = result
+ 
      test_histogram = ex12.histogram([1, 2, 3])
+     sys.stdout = std_out
+ 
+     result_string = result.getvalue()
+ 
- #    assert_equal(test_histogram, '*\n**\n***\n')
+     assert_equal(result_string, '*\n**\n***\n')
  
  
Update ex12 test so it actually reads output.
## Code Before:
from nose.tools import *
from exercises import ex12

def test_histogram():
    '''
    Test our histogram output is correct
    '''

    test_histogram = ex12.histogram([1, 2, 3])
#    assert_equal(test_histogram, '*\n**\n***\n')


## Instruction:
Update ex12 test so it actually reads output.
## Code After:
from nose.tools import *
from exercises import ex12
try:
    from io import StringIO
except:
    from StringIO import StringIO
import sys

def test_histogram():
    '''
    Test our histogram output is correct
    '''

    std_out = sys.stdout
    result = StringIO()
    sys.stdout = result

    test_histogram = ex12.histogram([1, 2, 3])
    sys.stdout = std_out

    result_string = result.getvalue()

    assert_equal(result_string, '*\n**\n***\n')

