def test_vars(self): greet2 = HelloWorld.Howdy() greet2.turd = "fartz" greeting2 = greet2.greeting("Foo") greet = HelloWorld.Howdy() greeting = greet.greeting("Foo") self.assertEqual(greeting, "Hello, Foo turdz") self.assertEqual(greeting2, "Hello, Foo fartz")
def __init__(self): self._matched_reader = 0 self._cvDiscovery = Condition() self.index = 0 factory = fastdds.DomainParticipantFactory.get_instance() self.participant_qos = fastdds.DomainParticipantQos() factory.get_default_participant_qos(self.participant_qos) self.participant = factory.create_participant(0, self.participant_qos) self.topic_data_type = HelloWorld.HelloWorldPubSubType() self.topic_data_type.setName("HelloWorld") self.type_support = fastdds.TypeSupport(self.topic_data_type) self.participant.register_type(self.type_support) self.topic_qos = fastdds.TopicQos() self.participant.get_default_topic_qos(self.topic_qos) self.topic = self.participant.create_topic( "HelloWorldTopic", self.topic_data_type.getName(), self.topic_qos) self.publisher_qos = fastdds.PublisherQos() self.participant.get_default_publisher_qos(self.publisher_qos) self.publisher = self.participant.create_publisher(self.publisher_qos) self.listener = WriterListener(self) self.writer_qos = fastdds.DataWriterQos() self.publisher.get_default_datawriter_qos(self.writer_qos) self.writer = self.publisher.create_datawriter(self.topic, self.writer_qos, self.listener)
def write(self): data = HelloWorld.HelloWorld() data.message("Hello World") data.index(self.index) self.writer.write(data) print("Sending {message} : {index}".format(message=data.message(), index=data.index())) self.index = self.index + 1
def testDivisibleByTwo(self): failedMessage = "divisibleByTwo Failed" self.assertEqual(True, hw.divisibleByTwo(2), failedMessage) self.assertEqual(True, hw.divisibleByTwo(4), failedMessage) self.assertEqual(True, hw.divisibleByTwo(108), failedMessage) self.assertEqual(True, hw.divisibleByTwo(10008), failedMessage) self.assertEqual(False, hw.divisibleByTwo(3), failedMessage) self.assertEqual(False, hw.divisibleByTwo(7), failedMessage) self.assertEqual(False, hw.divisibleByTwo(901), failedMessage) self.assertEqual(False, hw.divisibleByTwo(90000001), failedMessage)
def deployProjects(): if request.method == 'POST': hw="" if request.form['sentence'] !='' : hw = HelloWorld.helloWorld(request.form['sentence']) print(hw) return render_template('deployProjects.html',sentence=request.form['sentence'],hw=hw,deployProjectsActive="active") else: return render_template('deployProjects.html',sentimentActive="active")
def testSum2(self): failedMessage = "Sum Failed" self.assertEqual(5, hw.sum2(2, 3), failedMessage) self.assertEqual(4, hw.sum2(2, 2), failedMessage) self.assertEqual(10, hw.sum2(7, 3), failedMessage) self.assertEqual(90, hw.sum2(40, 50), failedMessage) self.assertEqual(15, hw.sum2(7, 8), failedMessage) self.assertEqual(0, hw.sum2(1, -1), failedMessage) self.assertEqual(0, hw.sum2(0, 0), failedMessage)
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 testCombineStrint(self): failedMessage = "combineString Failed" self.assertEqual("HelloWorld", hw.combineString("Hello", "World"), failedMessage) self.assertEqual("RainFall", hw.combineString("Rain", "Fall"), failedMessage) self.assertEqual(":-)", hw.combineString(":-", ")"), failedMessage)
import HelloWorld HelloWorld.__test()
def test_square(self): self.assertEqual(HelloWorld.square(3), 9)
import HelloWorld as HelloEarth if __name__ == "__main__": hey = HelloEarth.Hello("hey, how you doing?") bye = HelloEarth.GoodBye("Good bye!!") hey.greet() bye.greet()
while True: try: print(next(it)) except StopIteration: sys.exit() ''' print("-------------iter--------------------\n") print("-------------函数--------------------") def helloPrint(name): print("hello:", name) return helloPrint("宋觅源") print("-------------函数--------------------\n") print("-------------模块--------------------") #print('Python 路径为:', sys.path, '\n') # 这是错误写法,还要加入.py 才能用 # importHello('song') HelloWorld.importHello('songHello') print(sys.path) print("-------------模块--------------------\n")
def testNumTrans1(self): r = HelloWorld.numTrans("00000000") self.assertEqual(r, "00000000", "00000000 Test Failed!")
def testNumTrans3(self): r = HelloWorld.numTrans("04610460") self.assertEqual(r, "04600460", "04610460 Test Failed!")
import HelloWorld HelloWorld.printer()
import HelloWorld print(HelloWorld.HelloWorldFunction()) import HelloWorldTwo print(HelloWorldTwo.HelloTwoFunction()) import HelloThree print(HelloThree.HelloThreeFunction()) import DateTime print(DateTime.DateTimeFunction()) import ListOne print(ListOne.ListOneFunction())
def test_helloworld(self): self.assertEqual(HelloWorld.hello_world(), "Hello, World!")
def test_timesthree(self): self.assertEqual(HelloWorld.times_three(3), 9)
def test_count_char(self): self.assertEqual(HelloWorld.count_char(";"), 4)
def test_findsymbol(self): self.assertEqual(HelloWorld.find_symbol("BTC/WS"), 332) self.assertFalse(HelloWorld.find_symbol("Tacos"))
def test_buildtriangle(self): self.assertEqual(HelloWorld.half_pyramid(5), ["#", "##", "###", "####", "#####"])
def test_TestHelloWorld(self): out = StringIO() sys.stdout = out HelloWorld.HelloWorld() self.assertEqual(out.getvalue().strip(), "Hello, World!")
def test_bye(self): greet = HelloWorld.Howdy() greeting = greet.bye("Bar") self.assertEqual(greeting, "Adios, Baro")
def testSimpleCalc(self): r = HelloWorld.AddCalc(1, 3) self.assertEqual(r, 4, "Add Test Failed!")
def test_is_a_shit(self): greet = HelloWorld.Howdy() self.assertTrue(greet.is_a_shit())
def testNumTrans2(self): r = HelloWorld.numTrans("ffffffff") self.assertEqual(r, "fffefffe", "ffffffff Test Failed!")
def test_greeting(self): greet = HelloWorld.Howdy() greeting = greet.greeting("Foo") self.assertEqual(greeting, "Hello, Foo turdz")
task = Sniper.Task("task") task.setEvtMax(3) import PyDataStore task.createSvc("PyDataStoreSvc/DataStore") import HelloWorld task.property("algs").append("HelloAlg/SetAlg") x = task.find("SetAlg") print "Before setting properties" x.show() print x.property("VarString").set("GOD") x.property("VectorInt").set(range(6)) x.property("MapStrInt").set({"str%d" % v: v for v in range(6)}) print "After setting properties" x.show() y = HelloWorld.HelloPy("PyAlg") task.addAlg(y) z = task.createAlg("HelloAlg/GetAlg") #task.show() task.run()
import HelloWorld print (HelloWorld.HelloWorld())
def test_hello(): assert HelloWorld.HelloWorld("Leonhard Euler") == "Hello Leonhard Euler!"
def testHelloWorld(self): self.assertEqual("Hello World", hw.helloWorld(), "helloWorld failed")
import sys import os import HelloWorld print('the command line arguments are:') for i in sys.argv: print(i) print('\n\nThe python path is: ', sys.path, '\n') print(os.getcwd()) print("call hello world") HelloWorld.HelloWorld() print('hello world version:', HelloWorld.__version__) print("_________dir_________") dir(sys) dir()
def testDistance(self): failedMessage = "Distance Failed" self.assertEqual(0, hw.distance(0, 0, 0, 0), failedMessage) self.assertEqual(6, hw.distance(3, 3, 9, 3), failedMessage) self.assertEqual(31, hw.distance(30, 2, -1, 8), failedMessage) self.assertEqual(2, hw.distance(1, 1, 2, 3), failedMessage)
def app(redis): spec = importlib.util.spec_from_file_location("app.py", Path("apps") / "hello_world" / "1.0.0" / "src") app = HelloWorld(redis=redis, logger=None, console_logger=None) yield app
def test_cubed(self): self.assertEqual(HelloWorld.cube(3), 27)
def testHelloNameNotEquals(self): self.assertNotEqual("Hello Amit", code.helloName("Abhi"))
def testHelloNameDefault(self): self.assertEqual("Hello Sanku", code.helloName())
def testSummation(self): listOfInts = [] for _ in range(3): listOfInts.append(random.randint(1, 100)) self.assertEqual(sum(listOfInts), hw.summation(listOfInts), "Summation Failed")
#!/usr/bin/env jython # hello_world.py import HelloWorld HelloWorld.world() HelloWorld.earth() HelloWorld.moon() HelloWorld.somebody('Dewayne') HelloWorld.people( ['John', 'Paul', 'George', "Ringo"] ) print '\n###########################################' print '## Now lets do it to the jRuby generated class HelloWorldRuby' print '## MUST have the jRuby jars etc in the CLASSPATH' [rint '## Problem is deeper than just the CLASSPATH.\n'] import HelloWorldRuby HelloWorldRuby.world() HelloWorldRuby.earth() HelloWorldRuby.moon() HelloWorldRuby.somebody('Dewayne') HelloWorldRuby.people( ['John', 'Paul', 'George', "Ringo"] )
def testHelloNameEquals(self): self.assertEqual("Hello Amit", code.helloName("Amit"))
import HelloWorld HelloWorld.talk()