Changeset d28ca33


Ignore:
Timestamp:
2021-03-16T14:49:57Z (4 weeks ago)
Author:
/ <>
Children:
0167270
Parents:
1ba675c
Message:

less glob more verbose

File:
1 edited

Legend:

Unmodified
Added
Removed
  • .tests/test1.py

    r1ba675c rd28ca33  
    99OFFLINETEST = False
    1010RENAMETEST = True
    11 SHOWLOG = True
    12 
    13 FAILED = []
     11SHOWLOG = False
     12SHOWTESTLOG = True
    1413
    1514SEPARATOR = "="*60
     
    3231        self.sck.send((msg+'\r\n').encode())
    3332
    34     def send_priv_msg(self, recip, msg, loud = True):
     33    def send_priv_msg(self, recip, msg, loud = False):
    3534        self.send_raw('PRIVMSG '+recip+' :'+msg, loud)
    3635
     
    9291    return received
    9392
    94 def perform_test(clis, test_function, test_name):
    95     global FAILED
     93def perform_test(failed, clis, test_function, test_name):
     94    fail = False
    9695    for cli in clis:
    9796        cli.tmplog=""
     
    104103    else:
    105104        print("Test failed")
    106         FAILED += [test_name]
     105        failed += [test_name]
     106        fail = True
    107107
     108    if fail or SHOWTESTLOG:
    108109        for cli in clis:
    109110            if cli.tmplog != "":
     
    127128
    128129def message_test(clis):
    129     print("Test: Send message")
    130130    ret = msg_comes_thru(clis[0], clis[1], 'ohai <3')
    131131    ret = ret & msg_comes_thru(clis[1], clis[0], 'uwu *pounces*')
     
    151151    return ret
    152152
    153 def run_tests():
    154     global FAILED
     153def run_tests(failed):
    155154    clis = []
    156155    clis += [IrcClient('test1', 'asd')]
     
    160159
    161160    if YESTEST:
    162         perform_test(clis, yes_test, "Yes")
     161        perform_test(failed, clis, yes_test, "Yes")
    163162
    164163    for cli in clis:
    165164        cli.jabber_login()
     165
    166166    clis[0].add_jabber_buddy(clis[1].nick)
    167167
    168168    if MESSAGETEST:
    169         perform_test(clis, message_test, "Send message")
     169        perform_test(failed, clis, message_test, "Send message")
    170170
    171171    if BLOCKTEST:
    172         perform_test(clis, block_test, "Block user")
     172        perform_test(failed, clis, block_test, "Block user")
    173173
    174174    if RENAMETEST:
    175         perform_test(clis, rename_test, "Rename user")
     175        perform_test(failed, clis, rename_test, "Rename user")
    176176
    177     if FAILED or SHOWLOG:
     177    if failed or SHOWLOG:
    178178        print("")
    179179        for cli in clis:
     
    183183        print(SMOLPARATOR)
    184184
    185     if FAILED:
     185    if failed:
    186186        print("\n" + SEPARATOR + "\nSome test have failed:")
    187         for fail in FAILED:
     187        for fail in failed:
    188188            print(fail)
    189189    else:
     
    191191   
    192192if __name__ == "__main__":
    193     run_tests()
    194     if FAILED:
     193    failed = []
     194    run_tests(failed)
     195    if failed:
    195196        sys.exit(1)
Note: See TracChangeset for help on using the changeset viewer.