Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Challenge 10 (Unreviewed) #364

Merged
merged 5 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
challenge 10 in python: modified the function to accept input() and u…
…pdated the test to reflect that
  • Loading branch information
sarcodian committed Jan 11, 2017
commit a08e08af1d84240552ad12b168dc18266c6bd91a
5 changes: 4 additions & 1 deletion challenge_10/python/sarcodian/src/challenge_10.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def brackets(a_string):
def brackets():

a_string = input("Please enter a string to process: ")

brac_dict = {
'}' : '{',
']' : '[',
Expand Down
36 changes: 25 additions & 11 deletions challenge_10/python/sarcodian/src/challenge_10_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# we start by importing the unittest module
import unittest
from unittest import mock

# Next lets import our function that we intend to do testing on
#
Expand All @@ -10,18 +11,31 @@
# lets define our suite of tests as a class and lets inherit from unittest.TestCase
class TestBinaryMethods(unittest.TestCase):

def test_squareSort(self):
""" Tests from the READ.me used to test the non input version"""
def test_Brackets(self):
""" Tests from the READ.me """

self.assertEqual(brackets('{{{{{{{{{adfkjaefia}}}}}}}'), False)
self.assertEqual(brackets('{{{{{{{{{[[[[[[kadfa{{{{{{{((({daljfdaf({{{[]}}kaldjfs})})))}}}}}}}]]]]]]}kjfela}}}}}}}}'), True)
self.assertEqual(brackets('{{{[}}}}dafda'), False)
self.assertEqual(brackets('{{{{{{{{{}}}}}}}}}'), True)
self.assertEqual(brackets('[[[[[[[[[kafjalfeianfailfeja;fjai;efa;sfj]]]]]]]]]kjajdain'), True)
self.assertEqual(brackets('< blank >'), True)
self.assertEqual(brackets('((((((fjdalfeja((((alefjalisj(())))))))))))d'), True)
self.assertEqual(brackets(')))(((d'), False)
self.assertEqual(brackets('({)} '), False)
test_list = [
'{{{{{{{{{adfkjaefia}}}}}}}',
'{{{{{{{{{[[[[[[kadfa{{{{{{{((({daljfdaf({{{[]}}kaldjfs})})))}}}}}}}]]]]]]}kjfela}}}}}}}}',
'{{{[}}}}dafda',
'{{{{{{{{{}}}}}}}}}',
'[[[[[[[[[kafjalfeianfailfeja;fjai;efa;sfj]]]]]]]]]kjajdain',
'< blank >',
'((((((fjdalfeja((((alefjalisj(())))))))))))d',
')))(((d',
'({)} '
]

with mock.patch('builtins.input', side_effect=test_list):
self.assertEqual(brackets(), False)
self.assertEqual(brackets(), True)
self.assertEqual(brackets(), False)
self.assertEqual(brackets(), True)
self.assertEqual(brackets(), True)
self.assertEqual(brackets(), True)
self.assertEqual(brackets(), True)
self.assertEqual(brackets(), False)
self.assertEqual(brackets(), False)



Expand Down