Best Python code snippet using autotest_python
pa12-transcrpit.py
Source:pa12-transcrpit.py
...455>>> 456============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============457>>> 458============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============459>>> w.try_open()460Traceback (most recent call last):461 File "<pyshell#92>", line 1, in <module>462 w.try_open()463NameError: name 'w' is not defined464>>> 465============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============466>>> w.try_open()467False468>>> n.try_open()469True470>>> 471============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============472>>> a=Lockable("front door", "in the foyer", house_key, False, True)473Traceback (most recent call last):474 File "<pyshell#95>", line 1, in <module>475 a=Lockable("front door", "in the foyer", house_key, False, True)476NameError: name 'house_key' is not defined477>>> house_key = Thing('house_key', 'house')478>>> a =Lockable("front door", "in the foyer", house_key, False, True)479Traceback (most recent call last):480 File "<pyshell#97>", line 1, in <module>481 a =Lockable("front door", "in the foyer", house_key, False, True)482 File "/Users/janechoi/Documents/pa12-part1.py", line 69, in __init__483 super().__init(self, pname,plocation, popen = False)484AttributeError: 'super' object has no attribute '_Lockable__init'485>>> 486============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============487>>> a =Lockable("front door", "in the foyer", house_key, False, True)488Traceback (most recent call last):489 File "<pyshell#98>", line 1, in <module>490 a =Lockable("front door", "in the foyer", house_key, False, True)491 File "/Users/janechoi/Documents/pa12-part1.py", line 69, in __init__492 super().__init(self, pname,plocation, popen )493AttributeError: 'super' object has no attribute '_Lockable__init'494>>> 495============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============496>>> a =Lockable("front door", "in the foyer", house_key, False, True)497Traceback (most recent call last):498 File "<pyshell#99>", line 1, in <module>499 a =Lockable("front door", "in the foyer", house_key, False, True)500 File "/Users/janechoi/Documents/pa12-part1.py", line 69, in __init__501 super().__init__(self, pname,plocation,popen)502TypeError: __init__() takes from 3 to 4 positional arguments but 5 were given503>>> 504============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============505>>> a =Lockable("front door", "in the foyer", house_key, False, True)506Traceback (most recent call last):507 File "<pyshell#100>", line 1, in <module>508 a =Lockable("front door", "in the foyer", house_key, False, True)509 File "/Users/janechoi/Documents/pa12-part1.py", line 68, in __init__510 super().__init__(self, pname,plocation,popen)511TypeError: __init__() takes from 3 to 4 positional arguments but 5 were given512>>> 513============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============514>>> a =Lockable("front door", "in the foyer", house_key, False, True)515>>> a.description()516Traceback (most recent call last):517 File "<pyshell#102>", line 1, in <module>518 a.description()519 File "/Users/janechoi/Documents/pa12-part1.py", line 47, in description520 if self.open == True :521AttributeError: 'Lockable' object has no attribute 'open'522>>> a.key523<__main__.Thing object at 0x1102b3128>524>>> a.is_locked525True526>>> p.is_open527Traceback (most recent call last):528 File "<pyshell#105>", line 1, in <module>529 p.is_open530NameError: name 'p' is not defined531>>> a.is_open532False533>>> b =Lockable("ancient treasure chest", "at the bottom of the sea", rusty_key)534Traceback (most recent call last):535 File "<pyshell#107>", line 1, in <module>536 b =Lockable("ancient treasure chest", "at the bottom of the sea", rusty_key)537TypeError: __init__() missing 1 required positional argument: 'popen'538>>> b=Lockable("ancient treasure chest", "at the bottom of the sea", rusty_key)539Traceback (most recent call last):540 File "<pyshell#108>", line 1, in <module>541 b=Lockable("ancient treasure chest", "at the bottom of the sea", rusty_key)542TypeError: __init__() missing 1 required positional argument: 'popen'543>>> 544============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============545>>> b=Lockable("ancient treasure chest", "at the bottom of the sea", rusty_key)546>>> b.open547Traceback (most recent call last):548 File "<pyshell#110>", line 1, in <module>549 b.open550AttributeError: 'Lockable' object has no attribute 'open'551>>> b.is_open552False553>>> b.is_locked554False555>>> 556============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============557>>> chest.description()558'The ancient treasure chestat the bottom of the sea is closed but unlocked'559>>> 560============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============561>>> diary.description()562"The diaryunder Sam's bed is open"563>>> 564============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============565>>> diary.try_open()566>>> chest.try_open()567>>> 568============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============569>>> diary.try_open()570False571>>> chest.try_open()572True573>>> 574============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============575>>> newdiary_try_open()576Traceback (most recent call last):577 File "<pyshell#119>", line 1, in <module>578 newdiary_try_open()579NameError: name 'newdiary_try_open' is not defined580>>> newdiary.try_open()581False582>>> newdiary.description()583"The diary under Sam's bed is locked"584>>> diary.description()585"The diary under Sam's bed is open"586>>> diary.try_open()587False588>>> chest.description()589'The ancient treasure chest at the bottom of the sea is closed but unlocked'590>>> chest.try_open()591True592>>> chest.decription()593Traceback (most recent call last):594 File "<pyshell#126>", line 1, in <module>595 chest.decription()596AttributeError: 'Lockable' object has no attribute 'decription'597>>> chest.description()598'The ancient treasure chest at the bottom of the sea is closed but unlocked'599>>> 600============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============601>>> chest.description()602'The ancient treasure chest at the bottom of the sea is closed but unlocked'603>>> chest.try_open()604True605>>> chest.description()606'The ancient treasure chest at the bottom of the sea is open'607>>> 608============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============609>>> chest.description()610'The ancient treasure chest at the bottom of the sea is closed but unlocked'611>>> chest.try_unlock_with(rusty_key)612False613>>> diary.description()614"The diary under Sam's bed is open"615>>> diary.try_unlock_with(rusty_key)616False617>>> newdiary_description()618Traceback (most recent call last):619 File "<pyshell#135>", line 1, in <module>620 newdiary_description()621NameError: name 'newdiary_description' is not defined622>>> newdiary.description()623"The diary under Sam's bed is locked"624>>> newdiary.try_unlock_with(rusty_key)625True626>>> newdiary.description()627"The diary under Sam's bed is closed but unlocked"628>>> 629============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============630>>> door.description()631'The door at front door is locked'632>>> door.try_unlock_with(rusty_key)633False634>>> door.description()635'The door at front door is locked'636>>> door.try_unlock_with(house_key)637True638>>> door.description()639'The door at front door is closed but unlocked'640>>> 641============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============642***First, let's test the Thing class***643Creating house_key with name 'front door key' and location 'in your jacket pocket'...644>>> 645============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============646***First, let's test the Thing class***647Creating house_key with name 'front door key' and location 'in your jacket pocket'...648Thehouse key is in your jacket pocket649>>> 650============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============651***First, let's test the Thing class***652Creating house_key with name 'front door key' and location 'in your jacket pocket'...653The house key is in your jacket pocket654>>> 655============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============656***First, let's test the Thing class***657Creating house_key with name 'front door key' and location 'in your jacket pocket'...658The house key is in your jacket pocket659***Now, let's test the Openable class***660Creating window1 with name 'large window' and location 'in the south wall' , and open state True...661The large windowin the south wall is open662>>> 663============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============664***First, let's test the Thing class***665\Creating house_key with name 'front door key' and location 'in your jacket pocket'...666The house key is in your jacket pocket667\***Now, let's test the Openable class***668\Creating window1 with name 'large window' and location 'in the south wall' , and open state True...669The large windowin the south wall is open670>>> 671============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============672***First, let's test the Thing class***673 Creating house_key with name 'front door key' and location 'in your jacket pocket'...674The house key is in your jacket pocket675 ***Now, let's test the Openable class***676 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...677The large windowin the south wall is open678>>> 679============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============680 ***First, let's test the Thing class***681 Creating house_key with name 'front door key' and location 'in your jacket pocket'...682The house key is in your jacket pocket683 ***Now, let's test the Openable class***684 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...685The large windowin the south wall is open686>>> 687============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============688 ***First, let's test the Thing class***689 Creating house_key with name 'front door key' and location 'in your jacket pocket'...690The house key is in your jacket pocket691 ***Now, let's test the Openable class***692 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...693The large window in the south wall is open694>>> 695============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============696 ***First, let's test the Thing class***697 Creating house_key with name 'front door key' and location 'in your jacket pocket'...698The house key is in your jacket pocket699 ***Now, let's test the Openable class***700 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...701The large window in the south wall is open702 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...703The Harry Potter on the bookshelf is closed704>>> 705============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============706 ***First, let's test the Thing class***707 Creating house_key with name 'front door key' and location 'in your jacket pocket'...708The house key is in your jacket pocket709 ***Now, let's test the Openable class***710 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...711The large window in the south wall is open712Attempting to open window1...713Traceback (most recent call last):714 File "/Users/janechoi/Documents/pa12-part1.py", line 135, in <module>715 print('window1.try_open() returned the value' + window1.try_open())716TypeError: can only concatenate str (not "bool") to str717>>> 718============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============719 ***First, let's test the Thing class***720 Creating house_key with name 'front door key' and location 'in your jacket pocket'...721The house key is in your jacket pocket722 ***Now, let's test the Openable class***723 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...724The large window in the south wall is open725Attempting to open window1...726window1.try_open() returned the valueFalse727 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...728The Harry Potter on the bookshelf is closed729>>> 730============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============731 ***First, let's test the Thing class***732 Creating house_key with name 'front door key' and location 'in your jacket pocket'...733The house key is in your jacket pocket734 ***Now, let's test the Openable class***735 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...736The large window in the south wall is open737Attempting to open window1...738window1.try_open() returned the value False739The large window in the south wall is open740 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...741The Harry Potter on the bookshelf is closed742>>> 743============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============744 ***First, let's test the Thing class***745 Creating house_key with name 'front door key' and location 'in your jacket pocket'...746The house key is in your jacket pocket747 ***Now, let's test the Openable class***748 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...749The large window in the south wall is open750Attempting to open window1...751 window1.try_open() returned the value False752The large window in the south wall is open753 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...754The Harry Potter on the bookshelf is closed755>>> 756============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============757 ***First, let's test the Thing class***758 Creating house_key with name 'front door key' and location 'in your jacket pocket'...759The house key is in your jacket pocket760 ***Now, let's test the Openable class***761 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...762The large window in the south wall is open763\n Attempting to open window1...764window1.try_open() returned the value False765The large window in the south wall is open766 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...767The Harry Potter on the bookshelf is closed768>>> 769============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============770 ***First, let's test the Thing class***771 Creating house_key with name 'front door key' and location 'in your jacket pocket'...772The house key is in your jacket pocket773---------------------------------------------------------------------------------------------------------------------------774 ***Now, let's test the Openable class***775 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...776The large window in the south wall is open777Attempting to open window1...778window1.try_open() returned the value False779The large window in the south wall is open780 Now, a book ***781 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...782The Harry Potter on the bookshelf is closed783---------------------------------------------------------------------------------------------------------------------------784>>> 785============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============786 ***First, let's test the Thing class***787 Creating house_key with name 'front door key' and location 'in your jacket pocket'...788The house key is in your jacket pocket789-----------------------------------------------------------------------------------790 ***Now, let's test the Openable class***791 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...792The large window in the south wall is open793Attempting to open window1...794window1.try_open() returned the value False795The large window in the south wall is open796 Now, a book ***797 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...798The Harry Potter on the bookshelf is closed799-----------------------------------------------------------------------------------800>>> 801============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============802 ***First, let's test the Thing class***803 Creating house_key with name 'front door key' and location 'in your jacket pocket'...804The house key is in your jacket pocket805--------------------------------------------------------------------------------806 ***Now, let's test the Openable class***807 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...808The large window in the south wall is open809Attempting to open window1...810window1.try_open() returned the value False811The large window in the south wall is open812 Now, a book ***813 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...814The Harry Potter on the bookshelf is closed815--------------------------------------------------------------------------------816>>> 817============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============818--------------------------------------------------------------------------------819 ***First, let's test the Thing class***820 Creating house_key with name 'front door key' and location 'in your jacket pocket'...821The house key is in your jacket pocket822--------------------------------------------------------------------------------823 ***Now, let's test the Openable class***824 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...825The large window in the south wall is open826Attempting to open window1...827window1.try_open() returned the value False828The large window in the south wall is open829 #### Now, a book 830 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...831The Harry Potter on the bookshelf is closed832--------------------------------------------------------------------------------833>>> 834============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============835--------------------------------------------------------------------------------836 ***First, let's test the Thing class***837 Creating house_key with name 'front door key' and location 'in your jacket pocket'...838The house key is in your jacket pocket839--------------------------------------------------------------------------------840 ***Now, let's test the Openable class***841 #### a window 842 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...843The large window in the south wall is open844Attempting to open window1...845window1.try_open() returned the value False846The large window in the south wall is open847 #### a book 848 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...849The Harry Potter on the bookshelf is closed850--------------------------------------------------------------------------------851>>> 852============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============853--------------------------------------------------------------------------------854 ***First, let's test the Thing class***855 #### a house_key (Thing) 856 Creating house_key with name 'front door key' and location 'in your jacket pocket'...857The house key is in your jacket pocket858--------------------------------------------------------------------------------859 ***Now, let's test the Openable class***860 #### a window (Openable) 861 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...862The large window in the south wall is open863Attempting to open window1...864window1.try_open() returned the value False865The large window in the south wall is open866 #### a book (Openable)867 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...868The Harry Potter on the bookshelf is closed869--------------------------------------------------------------------------------870>>> 871============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============872--------------------------------------------------------------------------------873***First, let's test the Thing class***874 #### a house_key (Thing) 875Creating house_key with name 'front door key' and location 'in your jacket pocket'...876The house key is in your jacket pocket877--------------------------------------------------------------------------------878***Now, let's test the Openable class***879 #### a window (Openable) 880Creating window1 with name 'large window' and location 'in the south wall' , and open state True...881The large window in the south wall is open882Attempting to open window1...883window1.try_open() returned the value False884The large window in the south wall is open885 #### a book (Openable)886Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...887The Harry Potter on the bookshelf is closed888--------------------------------------------------------------------------------889>>> 890============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============891--------------------------------------------------------------------------------892***First, let's test the Thing class***893 #### a house_key (Thing) 894Creating house_key with name 'front door key' and location 'in your jacket pocket'...895The house key is in your jacket pocket896--------------------------------------------------------------------------------897***Now, let's test the Openable class***898 #### a window (Openable) 899Creating window1 with name 'large window' and location 'in the south wall' , and open state True...900The large window in the south wall is open901Attempting to open window1...902window1.try_open() returned the value False903The large window in the south wall is open904 #### a book (Openable)905Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...906The Harry Potter on the bookshelf is closed907Attempting to open book1...908book1.try_open() returned the value True909The Harry Potter on the bookshelf is open910--------------------------------------------------------------------------------911>>> 912============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============913--------------------------------------------------------------------------------914***First, let's test the Thing class***915 #### a house_key (Thing) 916 Creating house_key with name 'front door key' and location 'in your jacket pocket'...917The house key is in your jacket pocket918--------------------------------------------------------------------------------919***Now, let's test the Openable class***920 #### a window (Openable) 921 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...922The large window in the south wall is open923 Attempting to open window1...924window1.try_open() returned the value False925The large window in the south wall is open926 #### a book (Openable)927 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...928The Harry Potter on the bookshelf is closed929 Attempting to open book1...930book1.try_open() returned the value True931The Harry Potter on the bookshelf is open932--------------------------------------------------------------------------------933>>> 934============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============935--------------------------------------------------------------------------------936***First, let's test the Thing class***937 #### a house_key (Thing) 938 Creating house_key with name 'front door key' and location 'in your jacket pocket'...939The house key is in your jacket pocket940--------------------------------------------------------------------------------941***Now, let's test the Openable ***942 #### a window (Openable) 943 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...944The large window in the south wall is open945 Attempting to open window1...946window1.try_open() returned the value False947The large window in the south wall is open948 #### a book (Openable)949 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...950The Harry Potter on the bookshelf is closed951 Attempting to open book1...952book1.try_open() returned the value True953The Harry Potter on the bookshelf is open954--------------------------------------------------------------------------------955***And now, let's test the Lockable ***956 #### a door (Lockable) 957 Creating door1 with name 'Front door' and location 'at front door' ,key house_key, open state False, and locked status True...958The Front door at front door is locked959>>> 960============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============961--------------------------------------------------------------------------------962***First, let's test the Thing class***963 #### a house_key (Thing) 964 Creating house_key with name 'front door key' and location 'in your jacket pocket'...965The house key is in your jacket pocket966--------------------------------------------------------------------------------967***Now, let's test the Openable ***968 #### a window (Openable) 969 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...970The large window in the south wall is open971 Attempting to open window1...972window1.try_open() returned the value False973The large window in the south wall is open974 #### a book (Openable)975 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...976The Harry Potter on the bookshelf is closed977 Attempting to open book1...978book1.try_open() returned the value True979The Harry Potter on the bookshelf is open980--------------------------------------------------------------------------------981***And now, let's test the Lockable ***982 #### a door (Lockable) 983 Creating door1 with name 'Front door' and location 'at front of the house' ,key house_key, open state False, and locked status True...984The Front door at front of the house is locked985 Attempting to open door1...986door1.try_open() returned the valueFalse987The Front door at front of the house is locked988 #### a diary (Lockable) 989>>> 990============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============991--------------------------------------------------------------------------------992***First, let's test the Thing class***993 #### a house_key (Thing) 994 Creating house_key with name 'front door key' and location 'in your jacket pocket'...995The house key is in your jacket pocket996--------------------------------------------------------------------------------997***Now, let's test the Openable ***998 #### a window (Openable) 999 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1000The large window in the south wall is open1001 Attempting to open window1...1002window1.try_open() returned the value False1003The large window in the south wall is open1004 #### a book (Openable)1005 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1006The Harry Potter on the bookshelf is closed1007 Attempting to open book1...1008book1.try_open() returned the value True1009The Harry Potter on the bookshelf is open1010--------------------------------------------------------------------------------1011***And now, let's test the Lockable ***1012 #### a door (Lockable) 1013 Creating door1 with name 'Front door' and location 'at front of the house' ,key house_key, open state False, and locked status True...1014The Front door at front of the house is locked1015 Attempting to open door1...1016door1.try_open() returned the value False1017The Front door at front of the house is locked1018 Attempting to unlock door1 with rusty_key...1019Traceback (most recent call last):1020 File "/Users/janechoi/Documents/pa12-part1.py", line 174, in <module>1021 print('door1.try_unlock_with(rusty_key) returned the value ' + str(door1.try_unlock_with(rusty_key)))1022NameError: name 'rusty_key' is not defined1023>>> 1024============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1025--------------------------------------------------------------------------------1026***First, let's test the Thing class***1027 #### a house_key (Thing) 1028 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1029The house key is in your jacket pocket1030 #### a rusty_key (Thing) 1031 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1032The rusty key is in your jeans pocket1033--------------------------------------------------------------------------------1034***Now, let's test the Openable ***1035 #### a window (Openable) 1036 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1037The large window in the south wall is open1038 Attempting to open window1...1039window1.try_open() returned the value False1040The large window in the south wall is open1041 #### a book (Openable)1042 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1043The Harry Potter on the bookshelf is closed1044 Attempting to open book1...1045book1.try_open() returned the value True1046The Harry Potter on the bookshelf is open1047--------------------------------------------------------------------------------1048***And now, let's test the Lockable ***1049 #### a door (Lockable) 1050 Creating door1 with name 'Front door' and location 'at front of the house' ,key house_key, open state False, and locked status True...1051The Front door at front of the house is locked1052 Attempting to open door1...1053door1.try_open() returned the value False1054The Front door at front of the house is locked1055 Attempting to unlock door1 with rusty_key...1056Traceback (most recent call last):1057 File "/Users/janechoi/Documents/pa12-part1.py", line 182, in <module>1058 print('door1.try_unlock_with(rusty_key) returned the value ' + str(door1.try_unlock_with(rusty_key)))1059NameError: name 'rusty_key' is not defined1060>>> 1061============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1062--------------------------------------------------------------------------------1063***First, let's test the Thing class***1064 #### a house_key (Thing) 1065 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1066The front door key is in your jacket pocket1067 #### a rusty_key (Thing) 1068 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1069The front door key is in your jacket pocket1070--------------------------------------------------------------------------------1071***Now, let's test the Openable ***1072 #### a window (Openable) 1073 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1074The large window in the south wall is open1075 Attempting to open window1...1076window1.try_open() returned the value False1077The large window in the south wall is open1078 #### a book (Openable)1079 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1080The Harry Potter on the bookshelf is closed1081 Attempting to open book1...1082book1.try_open() returned the value True1083The Harry Potter on the bookshelf is open1084--------------------------------------------------------------------------------1085***And now, let's test the Lockable ***1086 #### a door (Lockable) 1087 Creating door1 with name 'Front door' and location 'at front of the house' ,key house_key, open state False, and locked status True...1088The Front door at front of the house is locked1089 Attempting to open door1...1090door1.try_open() returned the value False1091The Front door at front of the house is locked1092 Attempting to unlock door1 with rusty_key...1093door1.try_unlock_with(rusty_key) returned the value False1094The Front door at front of the house is locked1095 #### a diary (Lockable) 1096>>> 1097============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1098--------------------------------------------------------------------------------1099***First, let's test the Thing class***1100 #### a house_key (Thing) 1101 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1102The front door key is in your jacket pocket1103 #### a rusty_key (Thing) 1104 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1105The front door key is in your jacket pocket1106--------------------------------------------------------------------------------1107***Now, let's test the Openable ***1108 #### a window (Openable) 1109 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1110The large window in the south wall is open1111 Attempting to open window1...1112window1.try_open() returned the value False1113The large window in the south wall is open1114 #### a book (Openable)1115 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1116The Harry Potter on the bookshelf is closed1117 Attempting to open book1...1118book1.try_open() returned the value True1119The Harry Potter on the bookshelf is open1120--------------------------------------------------------------------------------1121***And now, let's test the Lockable ***1122 #### a door (Lockable) 1123 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked status True...1124The door at front of the house is locked1125 Attempting to open door1...1126door1.try_open() returned the value False1127The door at front of the house is locked1128 Attempting to unlock door1 with rusty_key...1129door1.try_unlock_with(rusty_key) returned the value False1130The door at front of the house is locked1131 #### a diary (Lockable) 1132>>> 1133============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1134--------------------------------------------------------------------------------1135***First, let's test the Thing class***1136 #### a house_key (Thing) 1137 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1138The front door key is in your jacket pocket1139 #### a rusty_key (Thing) 1140 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1141The front door key is in your jacket pocket1142--------------------------------------------------------------------------------1143***Now, let's test the Openable ***1144 #### a window (Openable) 1145 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1146The large window in the south wall is open1147 Attempting to open window1...1148window1.try_open() returned the value False1149The large window in the south wall is open1150 #### a book (Openable)1151 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1152The Harry Potter on the bookshelf is closed1153 Attempting to open book1...1154book1.try_open() returned the value True1155The Harry Potter on the bookshelf is open1156--------------------------------------------------------------------------------1157***And now, let's test the Lockable ***1158 #### a door (Lockable) 1159 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked status True...1160The door at front of the house is locked1161 Attempting to open door1...1162door1.try_open() returned the value False1163The door at front of the house is locked1164 Attempting to unlock door1 with rusty_key...1165door1.try_unlock_with(rusty_key) returned the value False1166The door at front of the house is locked1167 Attempting to unlock door1 with house_key...1168door1.try_unlock_with(house_key) returned the value True1169The door at front of the house is closed but unlocked1170 #### a diary (Lockable) 1171>>> 1172============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1173--------------------------------------------------------------------------------1174***First, let's test the Thing class***1175 #### a house_key (Thing) 1176 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1177The front door key is in your jacket pocket1178 #### a rusty_key (Thing) 1179 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1180The front door key is in your jacket pocket1181--------------------------------------------------------------------------------1182***Now, let's test the Openable ***1183 #### a window (Openable) 1184 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1185The large window in the south wall is open1186 Attempting to open window1...1187window1.try_open() returned the value False1188The large window in the south wall is open1189 #### a book (Openable)1190 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1191The Harry Potter on the bookshelf is closed1192 Attempting to open book1...1193book1.try_open() returned the value True1194The Harry Potter on the bookshelf is open1195--------------------------------------------------------------------------------1196***And now, let's test the Lockable ***1197 #### a door (Lockable) 1198 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked status True...1199The door at front of the house is locked1200 Attempting to open door1...1201door1.try_open() returned the value False1202The door at front of the house is locked1203 Attempting to unlock door1 with rusty_key...1204door1.try_unlock_with(rusty_key) returned the value False1205The door at front of the house is locked1206 Attempting to unlock door1 with house_key...1207door1.try_unlock_with(house_key) returned the value True1208The door at front of the house is closed but unlocked1209 Attempting to open door1...1210door1.try_open() returned the value True1211The door at front of the house is open1212 #### a diary (Lockable) 1213>>> 1214============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1215--------------------------------------------------------------------------------1216***First, let's test the Thing class***1217 #### a house_key (Thing) 1218 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1219The front door key is in your jacket pocket1220 #### a rusty_key (Thing) 1221 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1222The front door key is in your jacket pocket1223 #### a tiny_key (Thing) 1224 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1225--------------------------------------------------------------------------------1226***Now, let's test the Openable ***1227 #### a window (Openable) 1228 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1229The large window in the south wall is open1230 Attempting to open window1...1231window1.try_open() returned the value False1232The large window in the south wall is open1233 #### a book (Openable)1234 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1235The Harry Potter on the bookshelf is closed1236 Attempting to open book1...1237book1.try_open() returned the value True1238The Harry Potter on the bookshelf is open1239--------------------------------------------------------------------------------1240***And now, let's test the Lockable ***1241 #### a door (Lockable) 1242 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1243The door at front of the house is locked1244 Attempting to open door1...1245door1.try_open() returned the value False1246The door at front of the house is locked1247 Attempting to unlock door1 with rusty_key...1248door1.try_unlock_with(rusty_key) returned the value False1249The door at front of the house is locked1250 Attempting to unlock door1 with house_key...1251door1.try_unlock_with(house_key) returned the value True1252The door at front of the house is closed but unlocked1253 Attempting to open door1...1254door1.try_open() returned the value True1255The door at front of the house is open1256 #### a diary (Lockable) 1257 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1258The diary under clothes is open1259>>> 1260============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1261--------------------------------------------------------------------------------1262***First, let's test the Thing class***1263 #### a house_key (Thing) 1264 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1265The front door key is in your jacket pocket1266 #### a rusty_key (Thing) 1267 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1268The front door key is in your jacket pocket1269 #### a tiny_key (Thing) 1270 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1271--------------------------------------------------------------------------------1272***Now, let's test the Openable ***1273 #### a window (Openable) 1274 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1275The large window in the south wall is open1276 Attempting to open window1...1277window1.try_open() returned the value False1278The large window in the south wall is open1279 #### a book (Openable)1280 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1281The Harry Potter on the bookshelf is closed1282 Attempting to open book1...1283book1.try_open() returned the value True1284The Harry Potter on the bookshelf is open1285--------------------------------------------------------------------------------1286***And now, let's test the Lockable ***1287 #### a door (Lockable) 1288 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1289The door at front of the house is locked1290 Attempting to open door1...1291door1.try_open() returned the value False1292The door at front of the house is locked1293 Attempting to unlock door1 with rusty_key...1294door1.try_unlock_with(rusty_key) returned the value False1295The door at front of the house is locked1296 Attempting to unlock door1 with house_key...1297door1.try_unlock_with(house_key) returned the value True1298The door at front of the house is closed but unlocked1299 Attempting to open door1...1300door1.try_open() returned the value True1301The door at front of the house is open1302 #### a diary (Lockable) 1303 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1304The diary under clothes is open1305 Attempting to open my_diary...1306my_diary.try_open() returned the value False1307>>> 1308============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1309--------------------------------------------------------------------------------1310***First, let's test the Thing class***1311 #### a house_key (Thing) 1312 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1313The front door key is in your jacket pocket1314 #### a rusty_key (Thing) 1315 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1316The front door key is in your jacket pocket1317 #### a tiny_key (Thing) 1318 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1319--------------------------------------------------------------------------------1320***Now, let's test the Openable ***1321 #### a window (Openable) 1322 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1323The large window in the south wall is open1324 Attempting to open window1...1325window1.try_open() returned the value False1326The large window in the south wall is open1327 #### a book (Openable)1328 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1329The Harry Potter on the bookshelf is closed1330 Attempting to open book1...1331book1.try_open() returned the value True1332The Harry Potter on the bookshelf is open1333--------------------------------------------------------------------------------1334***And now, let's test the Lockable ***1335 #### a door (Lockable) 1336 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1337The door at front of the house is locked1338 Attempting to open door1...1339door1.try_open() returned the value False1340The door at front of the house is locked1341 Attempting to unlock door1 with rusty_key...1342door1.try_unlock_with(rusty_key) returned the value False1343The door at front of the house is locked1344 Attempting to unlock door1 with house_key...1345door1.try_unlock_with(house_key) returned the value True1346The door at front of the house is closed but unlocked1347 Attempting to open door1...1348door1.try_open() returned the value True1349The door at front of the house is open1350 #### a diary (Lockable) 1351 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1352The diary under clothes is open1353 Attempting to open my_diary...1354my_diary.try_open() returned the value False1355 Attempting to unlock my_diary with tiny_key...1356my_diary.try_unlock_with(tiny_key) returned the value False1357>>> 1358============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1359--------------------------------------------------------------------------------1360***First, let's test the Thing class***1361 #### a house_key (Thing) 1362 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1363The front door key is in your jacket pocket1364 #### a rusty_key (Thing) 1365 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1366The front door key is in your jacket pocket1367 #### a tiny_key (Thing) 1368 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1369--------------------------------------------------------------------------------1370***Now, let's test the Openable ***1371 #### a window (Openable) 1372 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1373The large window in the south wall is open1374 Attempting to open window1...1375window1.try_open() returned the value False1376The large window in the south wall is open1377 #### a book (Openable)1378 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1379The Harry Potter on the bookshelf is closed1380 Attempting to open book1...1381book1.try_open() returned the value True1382The Harry Potter on the bookshelf is open1383--------------------------------------------------------------------------------1384***And now, let's test the Lockable ***1385 #### a door (Lockable) 1386 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1387The door at front of the house is locked1388 Attempting to open door1...1389door1.try_open() returned the value False1390The door at front of the house is locked1391 Attempting to unlock door1 with rusty_key...1392door1.try_unlock_with(rusty_key) returned the value False1393The door at front of the house is locked1394 Attempting to unlock door1 with house_key...1395door1.try_unlock_with(house_key) returned the value True1396The door at front of the house is closed but unlocked1397 Attempting to open door1...1398door1.try_open() returned the value True1399The door at front of the house is open1400 #### a diary (Lockable) 1401 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1402The diary under clothes is open1403 Attempting to open my_diary...1404my_diary.try_open() returned the value False1405The diary under clothes is open1406 Attempting to unlock my_diary with tiny_key...1407my_diary.try_unlock_with(tiny_key) returned the value False1408The diary under clothes is open1409>>> 1410============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1411--------------------------------------------------------------------------------1412***First, let's test the Thing class***1413 #### a house_key (Thing) 1414 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1415The front door key is in your jacket pocket1416 #### a rusty_key (Thing) 1417 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1418The front door key is in your jacket pocket1419 #### a tiny_key (Thing) 1420 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1421--------------------------------------------------------------------------------1422***Now, let's test the Openable ***1423 #### a window (Openable) 1424 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1425The large window in the south wall is open1426 Attempting to open window1...1427window1.try_open() returned the value False1428The large window in the south wall is open1429 #### a book (Openable)1430 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1431The Harry Potter on the bookshelf is closed1432 Attempting to open book1...1433book1.try_open() returned the value True1434The Harry Potter on the bookshelf is open1435--------------------------------------------------------------------------------1436***And now, let's test the Lockable ***1437 #### a door (Lockable) 1438 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1439The door at front of the house is locked1440 Attempting to open door1...1441door1.try_open() returned the value False1442The door at front of the house is locked1443 Attempting to unlock door1 with rusty_key...1444door1.try_unlock_with(rusty_key) returned the value False1445The door at front of the house is locked1446 Attempting to unlock door1 with house_key...1447door1.try_unlock_with(house_key) returned the value True1448The door at front of the house is closed but unlocked1449 Attempting to open door1...1450door1.try_open() returned the value True1451The door at front of the house is open1452 #### a diary (Lockable) 1453 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1454The diary under clothes is open1455 Attempting to open my_diary...1456my_diary.try_open() returned the value False1457The diary under clothes is open1458 Attempting to unlock my_diary with tiny_key...1459my_diary.try_unlock_with(tiny_key) returned the value False1460The diary under clothes is open1461 #### an ancient treasure chest (Lockable) 1462 Creating chest with name 'ancient treasure chest' and location 'at the bottom of the sea' ,key rusty_key, and default open state and locked state...1463The ancient treasure chest at the bottom of the sea is closed but unlocked1464>>> 1465============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1466--------------------------------------------------------------------------------1467***First, let's test the Thing class***1468 #### a house_key (Thing) 1469 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1470The front door key is in your jacket pocket1471 #### a rusty_key (Thing) 1472 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1473The front door key is in your jacket pocket1474 #### a tiny_key (Thing) 1475 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1476--------------------------------------------------------------------------------1477***Now, let's test the Openable ***1478 #### a window (Openable) 1479 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1480The large window in the south wall is open1481 Attempting to open window1...1482window1.try_open() returned the value False1483The large window in the south wall is open1484 #### a book (Openable)1485 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1486The Harry Potter on the bookshelf is closed1487 Attempting to open book1...1488book1.try_open() returned the value True1489The Harry Potter on the bookshelf is open1490--------------------------------------------------------------------------------1491***And now, let's test the Lockable ***1492 #### a door (Lockable) 1493 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1494The door at front of the house is locked1495 Attempting to open door1...1496door1.try_open() returned the value False1497The door at front of the house is locked1498 Attempting to unlock door1 with rusty_key...1499door1.try_unlock_with(rusty_key) returned the value False1500The door at front of the house is locked1501 Attempting to unlock door1 with house_key...1502door1.try_unlock_with(house_key) returned the value True1503The door at front of the house is closed but unlocked1504 Attempting to open door1...1505door1.try_open() returned the value True1506The door at front of the house is open1507 #### a diary (Lockable) 1508 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1509The diary under clothes is open1510 Attempting to open my_diary...1511my_diary.try_open() returned the value False1512The diary under clothes is open1513 Attempting to unlock my_diary with tiny_key...1514my_diary.try_unlock_with(tiny_key) returned the value False1515The diary under clothes is open1516 #### an ancient treasure chest (Lockable) 1517 Creating chest with name 'ancient treasure chest' and location 'at the bottom of the sea' ,key rusty_key, and default open state and locked state...1518The ancient treasure chest at the bottom of the sea is closed but unlocked1519 Attempting to unlock chest with house_key...1520chest.try_unlock_with(house_key) returned the value False1521The ancient treasure chest at the bottom of the sea is closed but unlocked1522>>> 1523============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1524--------------------------------------------------------------------------------1525***First, let's test the Thing class***1526 #### a house_key (Thing) 1527 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1528The front door key is in your jacket pocket1529 #### a rusty_key (Thing) 1530 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1531The front door key is in your jacket pocket1532 #### a tiny_key (Thing) 1533 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1534--------------------------------------------------------------------------------1535***Now, let's test the Openable ***1536 #### a window (Openable) 1537 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1538The large window in the south wall is open1539 Attempting to open window1...1540window1.try_open() returned the value False1541The large window in the south wall is open1542 #### a book (Openable)1543 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1544The Harry Potter on the bookshelf is closed1545 Attempting to open book1...1546book1.try_open() returned the value True1547The Harry Potter on the bookshelf is open1548--------------------------------------------------------------------------------1549***And now, let's test the Lockable ***1550 #### a door (Lockable) 1551 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1552The door at front of the house is locked1553 Attempting to open door1...1554door1.try_open() returned the value False1555The door at front of the house is locked1556 Attempting to unlock door1 with rusty_key...1557door1.try_unlock_with(rusty_key) returned the value False1558The door at front of the house is locked1559 Attempting to unlock door1 with house_key...1560door1.try_unlock_with(house_key) returned the value True1561The door at front of the house is closed but unlocked1562 Attempting to open door1...1563door1.try_open() returned the value True1564The door at front of the house is open1565 #### a diary (Lockable) 1566 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1567The diary under clothes is open1568 Attempting to open my_diary...1569my_diary.try_open() returned the value False1570The diary under clothes is open1571 Attempting to unlock my_diary with tiny_key...1572my_diary.try_unlock_with(tiny_key) returned the value False1573The diary under clothes is open1574 #### an ancient treasure chest (Lockable) 1575 Creating chest with name 'ancient treasure chest' and location 'at the bottom of the sea' ,key rusty_key, and default open state and locked state...1576The ancient treasure chest at the bottom of the sea is closed but unlocked1577 Attempting to unlock chest with house_key...1578chest.try_unlock_with(house_key) returned the value False1579The ancient treasure chest at the bottom of the sea is closed but unlocked1580 Attempting to unlock chest with rusty_key...1581chest.try_unlock_with(rusty_key) returned the value False1582The ancient treasure chest at the bottom of the sea is closed but unlocked1583>>> 1584============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1585--------------------------------------------------------------------------------1586***First, let's test the Thing class***1587 #### a house_key (Thing) 1588 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1589The front door key is in your jacket pocket1590 #### a rusty_key (Thing) 1591 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1592The front door key is in your jacket pocket1593 #### a tiny_key (Thing) 1594 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1595--------------------------------------------------------------------------------1596***Now, let's test the Openable ***1597 #### a window (Openable) 1598 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1599The large window in the south wall is open1600 Attempting to open window1...1601window1.try_open() returned the value False1602The large window in the south wall is open1603 #### a book (Openable)1604 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1605The Harry Potter on the bookshelf is closed1606 Attempting to open book1...1607book1.try_open() returned the value True1608The Harry Potter on the bookshelf is open1609--------------------------------------------------------------------------------1610***And now, let's test the Lockable ***1611 #### a door (Lockable) 1612 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1613The door at front of the house is locked1614 Attempting to open door1...1615door1.try_open() returned the value False1616The door at front of the house is locked1617 Attempting to unlock door1 with rusty_key...1618door1.try_unlock_with(rusty_key) returned the value False1619The door at front of the house is locked1620 Attempting to unlock door1 with house_key...1621door1.try_unlock_with(house_key) returned the value True1622The door at front of the house is closed but unlocked1623 Attempting to open door1...1624door1.try_open() returned the value True1625The door at front of the house is open1626 #### a diary (Lockable) 1627 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1628The diary under clothes is open1629 Attempting to open my_diary...1630my_diary.try_open() returned the value False1631The diary under clothes is open1632 Attempting to unlock my_diary with tiny_key...1633my_diary.try_unlock_with(tiny_key) returned the value False1634The diary under clothes is open1635 #### an ancient treasure chest (Lockable) 1636 Creating chest with name 'ancient treasure chest' and location 'at the bottom of the sea' ,key rusty_key, and default open state and locked state...1637The ancient treasure chest at the bottom of the sea is closed but unlocked1638 Attempting to unlock chest with house_key...1639chest.try_unlock_with(house_key) returned the value False1640The ancient treasure chest at the bottom of the sea is closed but unlocked1641 Attempting to unlock chest with rusty_key...1642chest.try_unlock_with(rusty_key) returned the value False1643The ancient treasure chest at the bottom of the sea is closed but unlocked1644 Attempting to open chest...1645chest.try_open() returned the value True1646The ancient treasure chest at the bottom of the sea is open1647>>> 1648============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1649--------------------------------------------------------------------------------1650***First, let's test the Thing class***1651 #### a house_key (Thing) 1652 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1653The front door key is in your jacket pocket1654-----------------------------------------1655 #### a rusty_key (Thing) 1656 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1657The front door key is in your jacket pocket1658-----------------------------------------1659 #### a tiny_key (Thing) 1660 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1661--------------------------------------------------------------------------------1662***Now, let's test the Openable ***1663 #### a window (Openable) 1664 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1665The large window in the south wall is open1666 Attempting to open window1...1667window1.try_open() returned the value False1668The large window in the south wall is open1669-----------------------------------------1670 #### a book (Openable)1671 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1672The Harry Potter on the bookshelf is closed1673 Attempting to open book1...1674book1.try_open() returned the value True1675The Harry Potter on the bookshelf is open1676--------------------------------------------------------------------------------1677***And now, let's test the Lockable ***1678 #### a door (Lockable) 1679 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1680The door at front of the house is locked1681 Attempting to open door1...1682door1.try_open() returned the value False1683The door at front of the house is locked1684 Attempting to unlock door1 with rusty_key...1685door1.try_unlock_with(rusty_key) returned the value False1686The door at front of the house is locked1687 Attempting to unlock door1 with house_key...1688door1.try_unlock_with(house_key) returned the value True1689The door at front of the house is closed but unlocked1690 Attempting to open door1...1691door1.try_open() returned the value True1692The door at front of the house is open1693-----------------------------------------1694 #### a diary (Lockable) 1695 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1696The diary under clothes is open1697 Attempting to open my_diary...1698my_diary.try_open() returned the value False1699The diary under clothes is open1700 Attempting to unlock my_diary with tiny_key...1701my_diary.try_unlock_with(tiny_key) returned the value False1702The diary under clothes is open1703-----------------------------------------1704 #### an ancient treasure chest (Lockable) 1705 Creating chest with name 'ancient treasure chest' and location 'at the bottom of the sea' ,key rusty_key, and default open state and locked state...1706The ancient treasure chest at the bottom of the sea is closed but unlocked1707 Attempting to unlock chest with house_key...1708chest.try_unlock_with(house_key) returned the value False1709The ancient treasure chest at the bottom of the sea is closed but unlocked1710 Attempting to unlock chest with rusty_key...1711chest.try_unlock_with(rusty_key) returned the value False1712The ancient treasure chest at the bottom of the sea is closed but unlocked1713 Attempting to open chest...1714chest.try_open() returned the value True1715The ancient treasure chest at the bottom of the sea is open1716>>> 1717============== RESTART: /Users/janechoi/Documents/pa12-part1.py ==============1718--------------------------------------------------------------------------------1719***First, let's test the Thing class***1720 #### a house_key (Thing) 1721 Creating house_key with name 'front door key' and location 'in your jacket pocket'...1722The front door key is in your jacket pocket1723-----------------------------------------1724 #### a rusty_key (Thing) 1725 Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...1726The rusty key is in your jeans pocket1727-----------------------------------------1728 #### a tiny_key (Thing) 1729 Creating tiny_key with name 'tiny key' and location 'in the back yard'...1730The tiny key is in the back yard1731--------------------------------------------------------------------------------1732***Now, let's test the Openable ***1733 #### a window (Openable) 1734 Creating window1 with name 'large window' and location 'in the south wall' , and open state True...1735The large window in the south wall is open1736 Attempting to open window1...1737window1.try_open() returned the value False1738The large window in the south wall is open1739-----------------------------------------1740 #### a book (Openable)1741 Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...1742The Harry Potter on the bookshelf is closed1743 Attempting to open book1...1744book1.try_open() returned the value True1745The Harry Potter on the bookshelf is open1746--------------------------------------------------------------------------------1747***And now, let's test the Lockable ***1748 #### a door (Lockable) 1749 Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...1750The door at front of the house is locked1751 Attempting to open door1...1752door1.try_open() returned the value False1753The door at front of the house is locked1754 Attempting to unlock door1 with rusty_key...1755door1.try_unlock_with(rusty_key) returned the value False1756The door at front of the house is locked1757 Attempting to unlock door1 with house_key...1758door1.try_unlock_with(house_key) returned the value True1759The door at front of the house is closed but unlocked1760 Attempting to open door1...1761door1.try_open() returned the value True1762The door at front of the house is open1763-----------------------------------------1764 #### a diary (Lockable) 1765 Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...1766The diary under clothes is open1767 Attempting to open my_diary...1768my_diary.try_open() returned the value False1769The diary under clothes is open1770 Attempting to unlock my_diary with tiny_key...1771my_diary.try_unlock_with(tiny_key) returned the value False1772The diary under clothes is open1773-----------------------------------------1774 #### an ancient treasure chest (Lockable) 1775 Creating chest with name 'ancient treasure chest' and location 'at the bottom of the sea' ,key rusty_key, and default open state and locked state...1776The ancient treasure chest at the bottom of the sea is closed but unlocked1777 Attempting to unlock chest with house_key...1778chest.try_unlock_with(house_key) returned the value False1779The ancient treasure chest at the bottom of the sea is closed but unlocked1780 Attempting to unlock chest with rusty_key...1781chest.try_unlock_with(rusty_key) returned the value False1782The ancient treasure chest at the bottom of the sea is closed but unlocked1783 Attempting to open chest...1784chest.try_open() returned the value True1785The ancient treasure chest at the bottom of the sea is open...
test_file.py
Source:test_file.py
...188class TestFileVer(unittest.TestCase):189 backend = "h5py"190 filever = filepy.HDF_FF_VERSION191 fformat = filepy.FILE_FORMAT192 def try_open(self, mode):193 nix_file = nix.File.open(self.testfilename, mode)194 nix_file.close()195 def set_header(self, fformat=None, version=None, fileid=None):196 if fformat is None:197 fformat = self.fformat198 if version is None:199 version = self.filever200 if fileid is None:201 fileid = nix.util.create_id()202 self.h5root.attrs["format"] = fformat203 self.h5root.attrs["version"] = version204 self.h5root.attrs["id"] = fileid205 self.h5root.attrs["created_at"] = 0206 self.h5root.attrs["updated_at"] = 0207 if "data" not in self.h5root:208 self.h5root.create_group("data")209 self.h5root.create_group("metadata")210 def setUp(self):211 self.tmpdir = TempDir("vertest")212 self.testfilename = os.path.join(self.tmpdir.path, "vertest.nix")213 self.h5file = h5py.File(self.testfilename, mode="w")214 self.h5root = self.h5file["/"]215 def tearDown(self):216 self.h5file.close()217 self.tmpdir.cleanup()218 def test_read_write(self):219 self.set_header()220 self.try_open(nix.FileMode.ReadWrite)221 def test_read_only(self):222 ver_x, ver_y, ver_z = self.filever223 roversion = (ver_x, ver_y, ver_z+2)224 self.set_header(version=roversion)225 self.try_open(nix.FileMode.ReadOnly)226 with self.assertRaises(RuntimeError):227 self.try_open(nix.FileMode.ReadWrite)228 def test_no_open(self):229 ver_x, ver_y, ver_z = self.filever230 noversion = (ver_x, ver_y+3, ver_z+2)231 self.set_header(version=noversion)232 with self.assertRaises(RuntimeError):233 self.try_open(nix.FileMode.ReadWrite)234 with self.assertRaises(RuntimeError):235 self.try_open(nix.FileMode.ReadOnly)236 noversion = (ver_x, ver_y+1, ver_z)237 self.set_header(version=noversion)238 with self.assertRaises(RuntimeError):239 self.try_open(nix.FileMode.ReadWrite)240 with self.assertRaises(RuntimeError):241 self.try_open(nix.FileMode.ReadOnly)242 noversion = (ver_x+1, ver_y, ver_z)243 self.set_header(version=noversion)244 with self.assertRaises(RuntimeError):245 self.try_open(nix.FileMode.ReadWrite)246 with self.assertRaises(RuntimeError):247 self.try_open(nix.FileMode.ReadOnly)248 def test_bad_tuple(self):249 self.set_header(version=(-1, -1, -1))250 with self.assertRaises(RuntimeError):251 self.try_open(nix.FileMode.ReadOnly)252 self.set_header(version=(1, 2))253 with self.assertRaises(RuntimeError):254 self.try_open(nix.FileMode.ReadOnly)255 def test_bad_format(self):256 self.set_header(fformat="NOT_A_NIX_FILE")257 with self.assertRaises(InvalidFile):258 self.try_open(nix.FileMode.ReadOnly)259 def test_bad_id(self):260 self.set_header(fileid="")261 with self.assertRaises(RuntimeError):262 self.try_open(nix.FileMode.ReadOnly)263 # empty file ID OK for versions older than 1.2.0264 self.set_header(version=(1, 1, 1), fileid="")265 self.try_open(nix.FileMode.ReadOnly)266 self.set_header(version=(1, 1, 0), fileid="")267 self.try_open(nix.FileMode.ReadOnly)268 self.set_header(version=(1, 0, 0), fileid="")...
pa12-part1.py
Source:pa12-part1.py
...34 return 'The ' + self.name +' '+ self.location + ' is open'35 #when closed36 else:37 return 'The ' + self.name +' '+ self.location + ' is closed'38 def try_open(self):39 """returns the attempt of opening an object(False when object is already open)40 Openable -> bool"""41 #if opened status, try_open is False 42 if self.is_open == True:43 return False44 #when closed, try_open is True45 #and now the open status is changed to open(true)46 else:47 self.is_open = True 48 return True49class Lockable(Openable):50 """represents physical objects that can be unlocked and opened(subclass of Openable, Thing)51 Attributes: is_locked(bool), key(Thing)"""52 #constructor method 53 def __init__(self, pname , plocation, pkey, popen = False, plock= False):54 """constructor method accepting a name, location, whether is open , whether is locked55 Lockable, str,str, bool, bool -> None """56 #inherited from openable57 super().__init__(pname,plocation,popen)58 59 self.key = pkey60 self.is_locked = plock61 def description(self):62 """ returns a string that describes the obejct63 Lockable -> str"""64 #when opened, unlocked 65 if self.is_open == True and self.is_locked == False:66 return 'The ' + self.name +' ' + self.location + ' is open'67 #when closed, unlocked68 elif self.is_open == False and self.is_locked == False:69 return 'The ' + self.name +' ' + self.location + ' is closed but unlocked'70 else: #when open, locked & when closed, locked71 #when locked (no matter with open status)72 return 'The ' + self.name +' ' + self.location + ' is locked'73 def try_open(self):74 """fails to open the object if the object is locked, returns the attempt of opening an object(False when object is already open)75 Lockable -> bool"""76 #when locked, can't open 77 if self.is_locked == True:78 return False79 #when unlocked, try open is inherited from openable 80 else:81 #if unlock, open -> false82 #if unlock, close -> true 83 return super().try_open()84 def try_unlock_with(self, pthing):85 """returns the attempt of unlocking an object(False when object is already unlocked)86 Lockable, Thing -> bool"""87 #when unlocked, can't unlock -> false88 if self.is_locked == False: #when unlocked89 return False90 #when locked 91 else:92 #if the key is right 93 if self.key == pthing :94 #change lock state to unlock(false)95 self.is_locked = False96 97 return True98 #when key is wrong 99 else:100 #can't unlock101 return False102 103####################################################################104##################MAIN PROGRAM####################105####################################################################106print('--------------------------------------------------------------------------------')107print("***First, let's test the Thing class***")108print("\n #### a house_key (Thing) ")109print("\n Creating house_key with name 'front door key' and location 'in your jacket pocket'...")110house_key = Thing("front door key", "in your jacket pocket")111print(house_key.description())112print('-----------------------------------------')113print("\n #### a rusty_key (Thing) ")114print("\n Creating rusty_key with name 'rusty key' and location 'in your jeans pocket'...")115rusty_key = Thing("rusty key", "in your jeans pocket")116print(rusty_key.description())117print('-----------------------------------------')118print("\n #### a tiny_key (Thing) ")119print("\n Creating tiny_key with name 'tiny key' and location 'in the back yard'...")120tiny_key = Thing("tiny key", "in the back yard")121print(tiny_key.description())122print('--------------------------------------------------------------------------------')123print("***Now, let's test the Openable ***")124print("\n #### a window (Openable) ")125print("\n Creating window1 with name 'large window' and location 'in the south wall' , and open state True...")126window1 = Openable("large window", "in the south wall", True)127print(window1.description())128print('\n Attempting to open window1...')129print('window1.try_open() returned the value ' + str(window1.try_open()))130print(window1.description())131print('-----------------------------------------')132print("\n #### a book (Openable)")133print("\n Creating book1 with name 'Harry Potter ' and location 'on the bookshelf' , and default open state...")134book1 = Openable("Harry Potter", "on the bookshelf")135print(book1.description())136print('\n Attempting to open book1...')137print('book1.try_open() returned the value ' + str(book1.try_open()))138print(book1.description())139print('--------------------------------------------------------------------------------')140print("***And now, let's test the Lockable ***")141print("\n #### a door (Lockable) ")142print("\n Creating door1 with name 'door' and location 'at front of the house' ,key house_key, open state False, and locked state True...")143door1 = Lockable("door", " at front of the house ", house_key,False, True) 144print(door1.description())145print('\n Attempting to open door1...')146print('door1.try_open() returned the value ' +str(door1.try_open()))147print(door1.description())148print('\n Attempting to unlock door1 with rusty_key...')149print('door1.try_unlock_with(rusty_key) returned the value ' + str(door1.try_unlock_with(rusty_key)))150print(door1.description())151print('\n Attempting to unlock door1 with house_key...')152print('door1.try_unlock_with(house_key) returned the value ' + str(door1.try_unlock_with(house_key)))153print(door1.description())154print('\n Attempting to open door1...')155print('door1.try_open() returned the value ' +str(door1.try_open()))156print(door1.description())157print('-----------------------------------------')158print("\n #### a diary (Lockable) ")159print("\n Creating my_diary with name 'diary' and location 'under clothes' ,key tiny_key, open state True, and default locked state...")160my_diary =Lockable("diary", "under clothes", tiny_key, True)161print(my_diary.description())162print('\n Attempting to open my_diary...')163print('my_diary.try_open() returned the value '+ str(my_diary.try_open()))164print(my_diary.description())165print('\n Attempting to unlock my_diary with tiny_key...')166print('my_diary.try_unlock_with(tiny_key) returned the value ' +str(my_diary.try_unlock_with(tiny_key)))167print(my_diary.description())168print('-----------------------------------------')169print("\n #### an ancient treasure chest (Lockable) ")170print("\n Creating chest with name 'ancient treasure chest' and location 'at the bottom of the sea' ,key rusty_key, and default open state and locked state...")171chest =Lockable("ancient treasure chest", "at the bottom of the sea", rusty_key)172print(chest.description())173print('\n Attempting to unlock chest with house_key...')174print('chest.try_unlock_with(house_key) returned the value ' +str(chest.try_unlock_with(house_key)))175print(chest.description())176print('\n Attempting to unlock chest with rusty_key...')177print('chest.try_unlock_with(rusty_key) returned the value ' +str(chest.try_unlock_with(rusty_key)))178print(chest.description())179print('\n Attempting to open chest...')180print('chest.try_open() returned the value ' +str(chest.try_open()))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!