Changeset d28ca33
- Timestamp:
- 2021-03-16T14:49:57Z (4 years ago)
- Children:
- 0167270
- Parents:
- 1ba675c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
.tests/test1.py
r1ba675c rd28ca33 9 9 OFFLINETEST = False 10 10 RENAMETEST = True 11 SHOWLOG = True 12 13 FAILED = [] 11 SHOWLOG = False 12 SHOWTESTLOG = True 14 13 15 14 SEPARATOR = "="*60 … … 32 31 self.sck.send((msg+'\r\n').encode()) 33 32 34 def send_priv_msg(self, recip, msg, loud = True):33 def send_priv_msg(self, recip, msg, loud = False): 35 34 self.send_raw('PRIVMSG '+recip+' :'+msg, loud) 36 35 … … 92 91 return received 93 92 94 def perform_test( clis, test_function, test_name):95 global FAILED93 def perform_test(failed, clis, test_function, test_name): 94 fail = False 96 95 for cli in clis: 97 96 cli.tmplog="" … … 104 103 else: 105 104 print("Test failed") 106 FAILED += [test_name] 105 failed += [test_name] 106 fail = True 107 107 108 if fail or SHOWTESTLOG: 108 109 for cli in clis: 109 110 if cli.tmplog != "": … … 127 128 128 129 def message_test(clis): 129 print("Test: Send message")130 130 ret = msg_comes_thru(clis[0], clis[1], 'ohai <3') 131 131 ret = ret & msg_comes_thru(clis[1], clis[0], 'uwu *pounces*') … … 151 151 return ret 152 152 153 def run_tests(): 154 global FAILED 153 def run_tests(failed): 155 154 clis = [] 156 155 clis += [IrcClient('test1', 'asd')] … … 160 159 161 160 if YESTEST: 162 perform_test( clis, yes_test, "Yes")161 perform_test(failed, clis, yes_test, "Yes") 163 162 164 163 for cli in clis: 165 164 cli.jabber_login() 165 166 166 clis[0].add_jabber_buddy(clis[1].nick) 167 167 168 168 if MESSAGETEST: 169 perform_test( clis, message_test, "Send message")169 perform_test(failed, clis, message_test, "Send message") 170 170 171 171 if BLOCKTEST: 172 perform_test( clis, block_test, "Block user")172 perform_test(failed, clis, block_test, "Block user") 173 173 174 174 if RENAMETEST: 175 perform_test( clis, rename_test, "Rename user")175 perform_test(failed, clis, rename_test, "Rename user") 176 176 177 if FAILEDor SHOWLOG:177 if failed or SHOWLOG: 178 178 print("") 179 179 for cli in clis: … … 183 183 print(SMOLPARATOR) 184 184 185 if FAILED:185 if failed: 186 186 print("\n" + SEPARATOR + "\nSome test have failed:") 187 for fail in FAILED:187 for fail in failed: 188 188 print(fail) 189 189 else: … … 191 191 192 192 if __name__ == "__main__": 193 run_tests() 194 if FAILED: 193 failed = [] 194 run_tests(failed) 195 if failed: 195 196 sys.exit(1)
Note: See TracChangeset
for help on using the changeset viewer.