Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- pirateList = []
- maxLengthList = 6
- while len(pirateList) < maxLengthList:
- item = input("Argh! Enter the item: ")
- if item == "exit":
- break;
- else:
- pirateList.append(item)
- print(pirateList)
- print(pirateList)
- main()
- import unittest
- from unittest.mock import patch
- import io
- import sys
- from RunFile import main
- class GetInputTest(unittest.TestCase):
- @patch('builtins.input', side_effect=["bow", "arrow","exit"])
- def test_output(self,m):
- saved_stdout = sys.stdout
- try:
- out = io.StringIO()
- sys.stdout = out
- main()
- output = out.getvalue().strip()
- assert output.endswith('[bow, arrow]')
- finally:
- sys.stdout = saved_stdout
- if __name__ == "__main__":
- unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement