def test_range_downloading_with_steps(self): sys.argv.append("/msg xdcc_servbot xdcc send #1-3,2") main() self.check_content(1) self.assertFalse(os.path.isfile("2_test.txt")) self.check_content(3)
def test_range_downloading(self): sys.argv.append("/msg xdcc_servbot xdcc send #1-3") main() self.check_content(1) self.check_content(2) self.check_content(3)
def test_repeated_download(self): sys.argv.append("/msg xdcc_servbot xdcc send #2") with open("2_test.txt", 'w') as testtwo: testtwo.write("This is a Test File for XDCC File Transfers\n\n") testtwo.write("This is Pack 2") self.check_content(2) main() self.check_content(2) os.remove("2_test.txt") main() self.check_content(2)
def test_resume(self): sys.argv.append("/msg xdcc_servbot xdcc send #3") with open("3_test.txt", 'w') as testthree: testthree.write("This is a Test File for XDCC File Transfers\n\n" "This is Pack 3") self.check_content(3) with open("3_test.txt", 'rb') as testthree: binary = testthree.read() with open("3_test.txt", 'wb') as testthree: testthree.write(binary[0:int(len(binary) / 2)]) main() self.check_content(3)
def test_keyboard_interrupt(self): if sys.version_info[0] >= 3: exec("import builtins as __builtin__") in globals() # noinspection PyUnusedLocal def interrupt(arg): if arg == "No arguments passed. See --help for more details": raise KeyboardInterrupt() else: self.assertEqual("Thanks for using xdcc-dl!", arg) exec("real_print = __builtin__.print") in globals() exec("__builtin__.print = interrupt") in globals() main() exec("__builtin__.print = real_print") in globals()
def test_single_download(self): sys.argv.append("/msg xdcc_servbot xdcc send #1") main() self.check_content(1)
def test_no_arguments(self): try: main() self.assertEqual(True, False) except SystemExit: self.assertEqual(True, True)