コード例 #1
0
def test(text, rule_string):
    print("-" * 80)
    print(Fore.GREEN + "Rule tested:" + Style.RESET_ALL, rule_string)
    print(Fore.GREEN + "Input string:" + Style.RESET_ALL, text)
    stdout.write(Fore.CYAN + "Result: " + Style.RESET_ALL)
    calc.main(text, pretty_mode=True)
    print("-" * 80 + "\n")
コード例 #2
0
    def test_not_number(self):
        user_input = ['5', 'a', '-']
        with redirect_stdout(self.response):
            with patch('builtins.input', side_effect=user_input):
                calculator.main()

        self.assertFalse(self.response.getvalue() == '')
コード例 #3
0
    def test_sub(self):
        user_input = ['5', '4', '-']
        with redirect_stdout(self.response):
            with patch('builtins.input', side_effect=user_input):
                calculator.main()

        self.assertTrue('1' in self.response.getvalue())
コード例 #4
0
def main():
    print("""

    ꧁༒☬𝓢𝓽𝓾𝓭𝓮𝓷𝓽'𝓼 𝓗𝓮𝓵𝓹𝓮𝓻☬༒꧂
    1. Calculator
    2. Dna to mRNA converter
    3. Exit
    """)


    menu = input("Option:")

    if menu == "1": # go to calculator
        main_func = True
        calculator.main()
        
    elif menu == "2":
        main_func = True
        converter.main()

    elif menu == "3":
        exit()
        
    else:
        print("Invalid input. Please try again.")
コード例 #5
0
def test_calculator():
    assert calculator.main(
        ['', "examples/cart-4560.json", "examples/base-prices.json"]) == 4560
    assert calculator.main(
        ['', "examples/cart-9363.json", "examples/base-prices.json"]) == 9363
    assert calculator.main(
        ['', "examples/cart-9500.json", "examples/base-prices.json"]) == 9500
    assert calculator.main(
        ['', "examples/cart-11356.json", "examples/base-prices.json"]) == 11356
コード例 #6
0
    def test_invalid_operation(self):
        user_input = ['5', '4', 'v']
        with redirect_stdout(self.response):
            with patch('builtins.input', side_effect=user_input):
                calculator.main()

        value = self.response.getvalue()
        self.assertFalse('1' in value)
        self.assertFalse('9' in value)
        self.assertFalse('20' in value)
コード例 #7
0
def main():
    a = ''
    while a not in ('run', 'test'):
        print("Choose an option:\n\tRun\n\tTest")
        a = input("Your choice: ")
        a = a.lower()
    if a == "run":
        print("\n--Running Program--\n")
        student.main()
    elif a == "test":
        print("\n--Testing Program--\n")
        pytest.main(['-v'])
コード例 #8
0
def analyze(data):
	query = nlp.process(data)
	response = {}
	if(query['type'] == "wiki"):
		response = encyclopedia(query['subject'])
	if(query['type'] == "calc"):
		response = calculator.main(query['subject'])
	if(query['type'] == "error"):
		response = query
	return response
コード例 #9
0
def select(selection):
    #route to calculator
    if selection == '1':
        calculator.main()
        print()
        main()

    #route to compound interest calculator
    elif selection == '2':
        compoundInterestCalculator.main()
        print()
        main()

    #route to rock paper scissors game
    elif selection == '3':
        rockpaperscissors.main()
        print()
        main()

    #route to countoff game
    elif selection == '4':
        countoff.main()
        print()
        main()

    #route to tictactoe game
    elif selection == '5':
        tictactoe.main()
        print()
        main()

    #exit program
    elif selection == '6':
        print("Goodbye!")
        return

    #catch all invalid entries and restart main
    else:
        print("Invalid Entry!")
        print()
        main()
コード例 #10
0
ファイル: websocket.py プロジェクト: mjsky514/calculator
async def accept(websocket, path):
    while True:
        # 클라이언트로부터 메시지를 대기한다.
        data = await websocket.recv()
        print("receive : " + data)

        # 함수 위치

        data = main(data)

        print(data)

        # await websocket.send("echo : " + data)
        await websocket.send(data)
コード例 #11
0
def main():
    run = True
    while (run):
        print("1.CALCULATOR")
        print("2.REVERSE A NUMBER")
        print("3.PRIME OR NOT")
        print("4.MONTH NAME")
        print("5.SORTED OR NOT")
        print("6.EXIT")
        print("ENTER CHOICE: ")

        try:
            choice = int(input())

            if (choice == 1):
                calculator.main()

            elif (choice == 2):
                reverse.main()

            elif (choice == 3):
                isPrime.main()

            elif (choice == 4):
                month.main()

            elif (choice == 5):
                Sorted.main()

            elif (choice == 6):
                run = False

            else:
                print("INVALID INPUT!")

        except ValueError:
            print("INVALID CHOICE! ENTER A NUMBER\n")
コード例 #12
0
ファイル: keypad.py プロジェクト: ryanpepe2000/cmpt120pepe
def loopCalc(win,screen,numList,keyList,screenText):
    num = []
    i = 1
    while True:

            mouse = click(win,keyList)
            createNumber(win,num,numList,keyList,mouse,screenText)

            isplayScreen = display(win,i, num, numList,screenText)
            

            # Calls to calculate.py to compute solution
            if mouse == "=":
                solution = calculator.main(numList)
                screenText.setText(solution)

            # QUIT BUTTON
            if mouse == "Quit":
                win.close()
                pass
コード例 #13
0
 def test_multiplication(self):
     self.assertEqual(main("250*14.3"), 3575)
コード例 #14
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__8(self): #invalid character case
     with self.assertRaisesRegex(Exception, 'Invalid syntax'):
         calculator.main('3+')
コード例 #15
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__6(self): #invalid character case
     with self.assertRaisesRegex(Exception, 'Invalid character found: :'):
         calculator.main('4+5:1')
コード例 #16
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__4(self): #dividing by 0 case
     with self.assertRaisesRegex(Exception, 'Can not be divided by 0'):
         calculator.main('5+4/0')
コード例 #17
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__2(self): #one number case
     expected = 0
     actual = calculator.main('0')
     self.assertEqual(expected, actual)
コード例 #18
0
 def test_multiply(self):
     sys.argv = "scriptname 10 x 2".split()
     result = calculator.main()
     self.assertEqual(result, 20)
コード例 #19
0
 def test_parentheses(self):
     arg = '5*(2+1)'
     res = calculator.main(arg)
     res = float(res)
     self.failUnlessEqual(res, 15)
コード例 #20
0
 def test_times(self):
     arg = '5*4'
     res = calculator.main(arg)
     res = float(res)
     self.failUnlessEqual(res, 20)
コード例 #21
0
 def testMinus(self):
     arg = '1-2'
     res = calculator.main(arg)
     res = float(res)
     self.failUnlessEqual(res, -1)
コード例 #22
0
 def test_input_two(self, stdout):
     main()
     self.assertEqual(stdout.getvalue(), '0\n')
コード例 #23
0
 def test_input_one(self, stdout):
     main()
     self.assertEqual(stdout.getvalue(), '9\n')
コード例 #24
0
 def test_invalid_operator(self):
     sys.argv = "scriptname 10 $ 2".split()
     result = calculator.main()
     self.assertEqual(result, 'invalid input')
コード例 #25
0
 def test_divide(self):
     sys.argv = "scriptname 10 / 2".split()
     result = calculator.main()
     self.assertEqual(result, 5)
コード例 #26
0
 def test_nested_parentheses(self):
     arg = '5*(2+(3*2))'
     res = calculator.main(arg)
     res = float(res)
     self.failUnlessEqual(res, 40)
コード例 #27
0
ファイル: dashboard.py プロジェクト: jwinternet/dashboard
def main():
	"""
	Main module for all others, presents menus in loops for easy end-user accessibility and
	re-usability.
	:return:
	:rtype:
	"""
	# Try statement for catching errors
	try:
		# Continuous while loop that keeps the program going indefinitely
		while True:
			# Prints a long yellow line to separate sections of the menu
			my_tools.print_lines()
			# Program's banner, containing the name, version and date
			print(
				"\t\t\t\t\t\t\t",
				my_tools.PyColors.bold,
				my_tools.PyColors.Fg.light_yellow,
				" <<< Dashboard >>>",
				my_tools.PyColors.reset,
				"\n\n\t\t\t\t\t",
				my_tools.PyColors.Fg.light_green,
				"  Project Version <|> Last Updated\n\t\t\t\t\t\t\t",
				"  0.0.5         12/05/2020",
				my_tools.PyColors.reset
			)

			# Presents the user with a menu of options to choose from
			first_choice = input(
				"\n 1) General"
				"\n 2) Game of Chance"
				"\n 3) Release Notes"
				"\n 4) Quit"
				"\n\n Please select from one of the options listed above (1-4): "
			).strip()

			#
			if first_choice == "1":
				while True:
					my_tools.print_lines()
					print(
						"\t\t\t\t\t\t\t\t ",
						my_tools.PyColors.bold,
						my_tools.PyColors.Fg.dark_green,
						"General Module",
						my_tools.PyColors.reset
					)

					second_choice = input(
						"\n 1) Password Generator"
						"\n 2) Coin Flip"
						"\n 3) Random Number Generator"
						"\n 4) Calculator"
						"\n 5) Return To Main Menu"
						"\n\n Please select from one of the options listed above (1-5): "
					).strip()

					#
					if second_choice == "1":
						password_generator.main()

					#
					elif second_choice == "2":
						coin_flip.main()

					#
					elif second_choice == "3":
						random_number.main()

					#
					elif second_choice == "4":
						calculator.main()

					# Returns the user to the main menu
					elif second_choice == "5":
						break

			#
			elif first_choice == "2":

				#
				while True:
					my_tools.print_lines()
					print(
						"\n\t\t\t ",
						my_tools.PyColors.Bg.light_blue,
						"Test 2 Module",
						my_tools.PyColors.reset
					)
					second_choice = input(
						"\n 1) Test 1"
						"\n 2) Test 2"
						"\n 3) About Module"
						"\n 4) Return To Main Menu"
						"\n\n Please select from one of the options listed above (1-4): "
					).strip()
					try:
						#
						if int(second_choice) in range(1, 3):
							# Test.Test(second_choice)
							pass

						#
						elif second_choice == "3":
							# Test.Test.about_module()
							pass

						# Returns to the previous menu
						elif second_choice == "4":
							break

					# Protects the program from erroneous data being entered
					except ValueError:
						continue

			# How to section on reporting any issues with this program
			elif first_choice == "3":
				my_tools.print_lines()
				print(
					"\n\t\t\t ",
					my_tools.PyColors.Bg.light_blue,
					"Version 0.0.0 Release Notes",
					my_tools.PyColors.reset,
					"\n\n New Features:"
					"\n"
				)
				input("\n\n Press enter to continue...").strip()
				continue

			# Enables to user to exit the program without a keyboard interrupt
			elif first_choice == "4":
				print("\n\n ...Exiting program\n\n")
				sys.exit(0)

	# Gracefully ends the program when the user hits the 'control + c' keys
	except KeyboardInterrupt:
		print("\n\n ...Exiting program\n\n")
		sys.exit(0)
コード例 #28
0
 def test_multiple_parentheses(self):
     arg = '(3+5)*(1+2)'
     res = calculator.main(arg)
     res = float(res)
     self.failUnlessEqual(res, 24)
コード例 #29
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__3(self): #fractional case
     expected = -1.9
     actual = calculator.main('3.0+4.5*0.2-5.8')
     self.assertEqual(expected, actual)
コード例 #30
0
__author__ = "Caffe"

import calculator


arguments = calculator.parse_arguments()
calculator.main(arguments)
コード例 #31
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__5(self): #invalid syntax case
     with self.assertRaisesRegex(Exception, 'Invalid syntax'):
         calculator.main('2+3/')
コード例 #32
0
ファイル: test_calculator.py プロジェクト: marklap/Py300
 def test_subtract(self):
     sys.argv = "scriptname 10 - 2".split()
     result = calculator.main()
     self.assertEqual(result, 8)
コード例 #33
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__7(self): #invalid character case
     # with self.assertRaises(Exception):
     with self.assertRaisesRegex(Exception, 'Invalid syntax'):
         calculator.main('3+4-/5+1')
コード例 #34
0
ファイル: test_calculator.py プロジェクト: marklap/Py300
 def test_divide(self):
     sys.argv = "scriptname 10 / 2".split()
     result = calculator.main()
     self.assertEqual(result, 5)
コード例 #35
0
ファイル: unittest_calc.py プロジェクト: stepKeiH/homework
 def test__1(self): #normal case
     expected = -2
     actual = calculator.main('3-4/2*3+1')
     self.assertEqual(expected, actual)
コード例 #36
0
 def test_subtract(self):
     sys.argv = "scriptname 10 - 2".split()
     result = calculator.main()
     self.assertEqual(result, 8)
コード例 #37
0
 def test_tons_of_stuff(self):
     arg = '(5*(2+4)-9*5*2*(-1))+10'
     res = calculator.main(arg)
     res = float(res)
     self.failUnlessEqual(res, 130)
コード例 #38
0
# -*- encoding: utf-8 -*-
import calculator

if __name__ == '__main__':
    calculator.main()
コード例 #39
0
ファイル: test_calculator.py プロジェクト: marklap/Py300
 def test_add(self):
     sys.argv = "scriptname 2 + 3".split()
     result = calculator.main()
     self.assertEqual(result, 5)
コード例 #40
0
 def testPlus(self):
     arg = '1+2'
     res = calculator.main(arg)
     res = float(res)
     self.failUnlessEqual(res, 3)
コード例 #41
0
ファイル: test_calculator.py プロジェクト: marklap/Py300
 def test_multiply(self):
     sys.argv = "scriptname 10 x 2".split()
     result = calculator.main()
     self.assertEqual(result, 20)
コード例 #42
0
ファイル: app.py プロジェクト: DivyaVashistha/tkinter_basics
def calculator_app():
    calculator.main()
コード例 #43
0
ファイル: test_calculator.py プロジェクト: marklap/Py300
 def test_invalid_operator(self):
     sys.argv = "scriptname 10 $ 2".split()
     result = calculator.main()
     self.assertEqual(result, 'invalid input')
コード例 #44
0
 def test_add(self):
     sys.argv = "scriptname 2 + 3".split()
     result = calculator.main()
     self.assertEqual(result, 5)