def test_clock_angle(): name = 'test' data = {'hour': 9, 'minute': 0} req = Mock(get_json=Mock(return_value=data), args=data) # Call tested function assert main.calc(req) == 'Angle is {}!'.format(angle)
def home(): if request.method == 'POST': master = request.files['master'] today = request.files['today'] master.save(('A_Master.xlsx')) today.save(('A.xlsx')) calcA = calc('A') os.remove('A_ABSENT.xlsx') os.remove('A.xlsx') os.remove('A_Master.xlsx') return render_template('index.html', calc=calcA) return render_template('index.html')
def test_input2(self): with self.assertRaises(Exception): main.calc('')
def test_alg7(self): x = main.calc('255.255.255.255', '255.255.255.0') self.assertTrue(x == '255.255.255.0 255.255.255.0')
def test_calc_5_div_6 (): assert calc([6, '/', 5]) == 'six division five equally one point two'
def test_calc_with_none(self): given = None with self.assertRaises(TypeError): calc(given)
def test_calc_10_min_0 (): assert calc([10, '-', 0]) == 'ten minus zero equally ten'
def test_res2(self): x = main.calc('34.23.89.190', '34.23.101.190') x1 = main.calc('34.23.101.190', '34.23.89.190') self.assertEqual(x, x1)
def test_res3(self): x = main.calc('167.128.92.70', '167.128.92.17', '167.128.92.68', '152.139.27.80') self.assertTrue(x == '192.0.0.0 128.0.0.0')
def test_input5(self): with self.assertRaises(Exception): main.calc('-999.-999.-999.-999', '-999.-999.-999.-999')
def test_input6(self): with self.assertRaises(Exception): main.calc('ghjsfdgfhs')
def test_input4(self): with self.assertRaises(Exception): main.calc('999.999.999.999', '999.999.999.999')
def test_input3(self): with self.assertRaises(Exception): main.calc('123 3213')
from selenium.webdriver.common.by import * import main browser = main.get_connection('http://suninjuly.github.io/alert_accept.html ') submit_button = browser.find_element(By.CSS_SELECTOR, 'button.btn') browser.execute_script("return arguments[0].scrollIntoView(true)", submit_button) submit_button.click() confirm = browser.switch_to.alert confirm.accept() x_element = browser.find_element(By.CSS_SELECTOR, '.form-group .nowrap#input_value') calc_result = main.calc(x_element.text) input_answer_field = browser.find_element(By.CSS_SELECTOR, 'input#answer') input_answer_field.send_keys(calc_result) submit_button = browser.find_element(By.CSS_SELECTOR, 'button.btn') browser.execute_script("return arguments[0].scrollIntoView(true)", submit_button) submit_button.click()
def test_calc_with_various_odd(self): given = (1, 3, 5, 6, 7) target = calc(given) expected = 20 self.assertEqual(target, expected)
def test_alg1(self): x = main.calc('122.22.22.2', '122.22.22.2') self.assertTrue(x == '255.255.255.255 122.22.22.2')
def test_calc_with_empty(self): given = () target = calc(given) expected = 0 self.assertEqual(target, expected)
def test_alg2(self): x = main.calc('0.0.0.0', '0.0.0.0') self.assertTrue(x == '255.255.255.255 0.0.0.0')
def test_calc(self): given = (1, 2, 3, 4, 5) target = calc(given) expected = 15 self.assertEqual(target, expected)
def test_input1(self): with self.assertRaises(Exception): main.calc('34.23.89.190')
def test_calc_3_m46 (): assert calc([3, '*', -46]) == 'three multiplication minus forty-six equally minus one hundred and thirty-eight'
def test_alg5(self): x = main.calc('1.2.3.4', '128.5.7.8') self.assertTrue(x == '0.0.0.0 0.0.0.0')
def test_calc_999_pl_2 (): assert calc([999, '+', 2]) == 'nine hundred and ninety-nine plus two equally one thousand and one'
def test_alg6(self): x = main.calc('255.255.255.255', '255.255.255.255', '255.255.255.255', '255.255.255.255', '255.255.255.255', '0.0.0.0') self.assertTrue(x == '0.0.0.0 0.0.0.0')
m[x1, y1] += 1 m[x2, y2] += 1 m[x2, y1] -= 1 m[x1, y2] -= 1 print("*2") mt = defaultdict(int) for y in range(0, K2): for x in range(0, K2): mt[x, y] = m[x, y] + mt[x - 1, y] + mt[x, y - 1] - mt[x - 1, y - 1] print("*3") rmax = 0 for y in range(K, K2): for x in range(K, K2): rcount = mt[x, y] rmax = max(rmax, rcount, N - rcount) return rmax import random N = 200 K = 5 xyc = [(random.randint(0, 10000), random.randint(0, 10000), random.randint(0, 10000) % 2) for i in range(N)] print(calc(K, xyc)) print(calc0(K, xyc))
def test_print_hello_world(): data = {} req = Mock(get_json=Mock(return_value=data), args=data) # Call tested function assert main.calc(req) == 'Angle is {}'.format(angle)