Oops!
On Fri, Oct 7, 2016 at 8:26 PM, boB Stepp <[email protected]> wrote:
> I think I have this figured out, but I want to be certain I am doing
> it both correctly and in the preferred way. I have a need for a
> get_input() function and have written my first test for this function
> as follows:
>
> class TestGetInput(unittest.TestCase):
> '''Tests for the function get_input().'''
>
> def setUp(self):
> '''Establish conditions for running these tests.'''
>
> # Redirect sys.stdin in order to test input functions.
> self.old_stdin = sys.stdin
> sys.stdin = StringIO('5')
>
> def test_get_input(self):
> '''Test that get_input() returns the expected result.'''
>
> expected = 5
> draw2x2grid.get_input()
> self.assertEqual(sys.stdin.getvalue(), expected)
My brain was scrambled. The test_get_input(self) should instead be:
def test_get_input(self):
'''Test that get_input() returns the expected result.'''
expected = 5
self.assertEqual(draw2x2grid.get_input(), expected)
boB
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor