def test_silly_placeholder(): """ Test for silly placeholder in {{cookiecutter.project_slug}}.py """ want = "Hello {{cookiecutter.project_slug}}" got = hello() assert got == want
def application(environ, start_response): results = [] results.append(str(moduletest.ageofqueen)) results.append(printhello()) results.append(hello()) helloWorld = HelloWorld() results.append(helloWorld.sayHello()) user = Users() results.append(user.sayHello()) article = Articles() results.append(article.sayHello()) output = "<br/>".join(results) print output # build the response body possibly using the environ dictionary response_body = output # HTTP response code and message status = '200 OK' # These are HTTP headers expected by the client. # They must be wrapped as a list of tupled pairs: # [(Header name, Header value)]. response_headers = [('Content-Type', 'text/html'), ('Content-Length', str(len(response_body)))] # Send them to the server using the supplied function start_response(status, response_headers) # Return the response body. # Notice it is wrapped in a list although it could be any iterable. return [response_body]
def main( name: str = typer.Option(..., help="Name of person to greet."), color: Optional[Color] = typer.Option( None, case_sensitive=False, help="Color for name. If not specified then choice will be random.", ), version: bool = typer.Option( None, "--version", callback=version_callback, is_eager=True, help="Prints the version of the {{ cookiecutter.project_name }} package.", ), ): """Prints a greeting for a giving name.""" if color is None: # If no color specified use random value from `Color` class color = random.choice(list(Color.__members__.values())) greeting: str = hello(name) console.print(f"[bold {color}]{greeting}[/]")
#!/usr/bin/env python from ../dir2/c import hello hello()
import os from hello import * a = 5 print(a + 1) assert a == 5 assert hello() == 10
import hello text = input("Your text: ") text2 = input("Your new text: ") hello.hello(text) hello.newfunction(text2) #if we need only 1 function from module, we can import only this function from hello import newfunction newfunction(text2) #if we want to use shorter form we can import all (*) from module from hello import * hello(text) #we can't use module's name (hello.hello() etc.) newfunction(text2) #if we have 2 function (the same name): from hello import hello as hello_hello text3 = input("Text3 = ") def hello(text3): print(text3) hello(text3) hello_hello(text)
import hello hello('wyy')
#!python from hello import * hello('Everyone')
def test_hello(self): self.assertEqual(hello(), 'Hello, world !')
def test_hello(self): self.assertEqual(hello("andrei"), "approved by: andrei")
def test_hello_roxana(self): self.assertEqual(hello("roxana"), "approved by: roxana")
def test_hello(): assert hello() is None
def test_hello_empty(self): self.assertEqual(hello(), "approved by: mata")
def test_install_hook(self): brainfuck.install_import_hook() import hello self.assertEqual(hello(), "Hello World!\n")
def test_hello(): hello()
#!/usr/bin/env python from hello import * print("Calling DSO") hello('World') print("Done")
def test_install_hook(self): brainfuck.install_import_hook() import hello self.assertEqual(hello(), "Hello World!\n")
print(sum%count) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def hello( N, M , symbol): #for i in range(): print((symbol*N + '\n') * M) def exeption_pass(): pass print(exeption_pass()) def exeption_return(): return 1 print(exeption_return()) hello(2,3,'$') def safe_div(x, y): """Do a safe division :-) for fun and profit""" if y != 0: z = x / y print(z) return(z) else: print("Yippie-kay-yay, motherf___er!") safe_div(10, 1) print(safe_div.__doc__)
def test_hello(): assert hello() == "hello"
def test_hello(name, expected): """Example test with parametrization.""" assert hello(name) == expected
def test_example(mock_example): s = hello("World") assert "Hello" in s
def main(): while 1: hello() while 1: try: option = int(input(': ')) if option > 0 and option < 6: break else: print('请输入正确信息!') except: print('请输入正确信息!') if option == 1: # 添加数据 while 1: insert_option = insert_options() if insert_option == 1: # 新建表 while 1: try: table_name = input('请输入表名: ') if table_name in query_table(switch=1): print('%s表已存在!' % table_name) break else: create_table(table_name) break except: print('请从新输入!') elif insert_option == 2: # 添加人物 while 1: table_list = query_table() table_option = input('请选择要添加人物的表号,如不更改按q返回\n:') try: if table_option == 'q': break elif int(table_option) > len(table_list): print('超出总表数,请从新选择。') pass else: table_name = table_list[int(table_option) - 1] print('进入%s表' % table_name) id_title = 'id: ' id = input_id(id_title) judge = query_id(table_name, id=id) while 1: i = 1 if judge == 1: select_option = input('此id已存在:\n1.更新此id数据\n2.输入新id\n3.上一级\n: ') if select_option == '1': break elif select_option == '2': while 1: try: id = int(input('id: ')) break except: print('请输入正确信息!') break elif select_option == '3': i = 0 break else: print('请输入正确信息!') else: break if i == 1: name = input('name: ') age_title = 'age: ' age = input_age(age_title) insert_into(table_name, id, name, age) except: print('请输入正确信息') elif insert_option == 3: break elif option == 2: # 查询数据 while 1: query_header() query_list = query_table() query_option = input('请选择要查询人物的表号,如不查询按q返回\n: ') try: if query_option == 'q': break elif int(query_option) > len(query_list): print('超出总表数,请从新选择。') pass else: while 1: table_name = query_list[int(query_option) - 1] print('进入%s表' % table_name) select_option = input('1.id查找\n2.name查找\n3.age查找\n4.展示所有\nq.返回\n') if select_option == '1': id_title = '请输入需要查询的id\n: ' id = input_id(id_title) query_data(table_name, id=id) option_quit = input('按任意键返回') break elif select_option == '2': name = input('请输入需要查询的name\n: ') query_data(table_name, name=name) option_quit = input('按任意键返回') break elif select_option == '3': big_age_title = '请输入需要查询的最大age\n: ' big_age = input_age(big_age_title) small_age_title = '请输入需要查询的最小age\n: ' small_age = input_age(small_age_title) query_data(table_name, big_age=big_age, small_age=small_age) option_quit = input('按任意键返回') break elif select_option == '4': query_data(table_name) option_quit = input('按任意键返回') break elif select_option == 'q': break else: print('请输入正确信息!') # 跳出本次循环 continue except: print('请输入正确信息!') elif option == 3: # 更改数据 while 1: updata_option = updata_options() if updata_option == 1: query_list = query_table() while 1: table_name = input('请输入要更改的表名\n: ') if table_name not in query_list: print('%s表不存在, 请从新输入\n: ' % table_name) else: break while 1: new_table_name = input('请输入新的表名\n: ') if table_name in query_list: print('%s表已存在, 请从新输入\n: ' % new_table_name) else: break new_table_name = input('请输入新的表名\n: ') rename_table(table_name, new_table_name) elif updata_option == 2: while 1: table_list = query_table() table_option = input('请选择要更新人物的表号,如不查询按q返回\n: ') try: if table_option == 'q': break elif int(table_option) > len(table_list): print('超出总表数,请从新选择。') pass else: while 1: table_name = table_list[int(table_option) - 1] print('进入%s表' % table_name) id_title = '请输入要更新的id: ' id = input_id(id_title) judge = query_id(table_name, id) i = 1 if judge != 1: while 1: judge_option = input('id%s未在%s中!\n1.添加新人物\n2.返回\n: ' % (id, table_name)) if judge_option == '1': i = 1 break elif judge_option == '2': i = 0 break else: print('请输入正确信息!') if i == 1: name = input('请输入此id更新的name: ') age_title = '请输入此id更新的age: ' age = input_age(age_title) insert_or_update(table_name, id, name, age) break except: print('请输入正确信息!') elif updata_option == 3: # 返回上一级 break continue elif option == 4: # 删除数据 while 1: delete_option = delete_options() if delete_option == 1: # 删除表 table_list = query_table() table_option = input('请选择要删除的表号,如不删除按q返回\n: ') try: if table_option == 'q': break elif int(table_option) > len(table_list): print('超出总表数,请从新选择。') pass else: table_name = table_list[int(table_option) - 1] delete_table(table_name) except: print('请输入有效信息!') elif delete_option == 2: # 删除人物 table_list = query_table() delete_table_option = input('请选择要删除人物的表号,如不删除按q返回\n: ') try: if delete_table_option == 'q': break elif int(delete_table_option) > len(table_list): print('超出总表数,请从新选择。') else: while 1: table_name = table_list[int(delete_table_option) - 1] query_data(table_name) delete_id = input('请输入要删除的id, 如不删除按q返回\n: ') try: if delete_id == 'q': break elif int(delete_id): delete_id = int(delete_id) judge = query_id(table_name, id=delete_id) if judge == 1: delete_field(table_name, delete_id) else: print('id:%s 不存在!' % delete_id) else: print('请输入有效信息!') except: print('请输入有效信息!') except: print('请输入有效信息!') elif delete_option == 3: # 返回上一级 break elif option == 5: # 退出程序 print('系统退出成功') db_close() break
def test_content(): """Greet correctly.""" assert hello('John') == 'Hello John'
def main(): print("This is the main function.") hello()
def main(): hello() try: world() except Exception as e: print(e)
def test_hello(): results = hello() assert results == "Hello!"