BME-MIT-IET / iet-hf-2022-holnapejfeligszerintemmindlepjunkbe

iet-hf-2022-holnapejfeligszerintemmindlepjunkbe created by GitHub Classroom
MIT License
0 stars 0 forks source link

test_array print redirection error #6

Open DrCash-KMark opened 2 years ago

DrCash-KMark commented 2 years ago

When testing the arrays in test_array I cannot redirect the output. I always get the "OSError: [WinError 6] The handle is invalid" error.

The code I used:

def test_print_intervals(self):
        interval_list = [[1, 3], [2, 6], [8, 10], [15, 18]]

        capturedOutput = io.StringIO()               # Create StringIO object
        sys.stdout = capturedOutput                  #  and redirect stdout.        
        Interval.print_intervals(interval_list)         # Call unchanged function.
        sys.stdout = sys.__stdout__                      # Reset redirect.

source: https://stackoverflow.com/questions/33767627/python-write-unittest-for-console-print