Exemplo n.º 1
0
 def test_valid_string_alternating_capitalized_letters(self, mock_input):
     # with unittest.mock.patch('volumeOfCube.retrieve_input', return_value=-1):
     capturedOutput = io.StringIO()  # Create StringIO object
     sys.stdout = capturedOutput  #  and redirect stdout.
     palindrome.main()  # Call function.
     sys.stdout = sys.__stdout__  # Reset redirect.
     expected = ['True', '']
     actual = capturedOutput.getvalue().split('\n')
     self.assertEqual(actual, expected)
Exemplo n.º 2
0
def main():
    """Find longest subpalindrome in War and Peace."""

    with open('war_and_peace_gutenberg.txt', 'r') as f:
        text = f.read()

    assert palindrome.main(text) == 'ton did not'
    return True
Exemplo n.º 3
0
def test_valid_string_alternating_capitalized_letters(monkeypatch):
    test_string = StringIO('tAcOcAt\n')
    monkeypatch.setattr('sys.stdin', test_string)
    assert palindrome.main() == True
Exemplo n.º 4
0
def test_valid_string(monkeypatch):
    test_string = StringIO('tacocat\n')
    monkeypatch.setattr('sys.stdin', test_string)
    assert palindrome.main() == True
Exemplo n.º 5
0
def test_empty_string(monkeypatch):
    test_string = StringIO('\n')
    monkeypatch.setattr('sys.stdin', test_string)
    assert palindrome.main() == True
Exemplo n.º 6
0
def test_bad_string(monkeypatch):
    test_string = StringIO('Thisisanactivity\n')
    monkeypatch.setattr('sys.stdin', test_string)
    assert palindrome.main() == False
 def main_op(self, tst_str, mock_stdout):
     with mock.patch('builtins.input', side_effect=tst_str):
         palindrome.main()
     return mock_stdout.getvalue()
Exemplo n.º 8
0
 def test_input_two(self, stdout):
     main()
     self.assertEqual(stdout.getvalue(), 'False\n')
Exemplo n.º 9
0
 def test_input_one(self, stdout):
     main()
     self.assertEqual(stdout.getvalue(), 'True\n')
 def main_op(self, tst_str, mock_stdout):
     with mock.patch('builtins.input', side_effect=tst_str):
         palindrome.main()
     return mock_stdout.getvalue()