예제 #1
0
def test():
  marks = 0;
  name = "Question 3"
  
  input = "Bob"
  expected = "Hello Bob"
  actual = hello.greet(input)
  if expected == actual:
    marks = marks+1

  input = ""
  expected = "Hello "
  actual = hello.greet(input)
  if expected == actual:
    marks = marks+1
  
  input = "Bob"
  expected = "Hello Bob"
  actual = "This-is-rigged"
  if expected == actual:
    marks = marks+1
    
  if marks == 3:
       status = "pass"
  else: 
      status = "fail"
    
  return printResults(name, status)
def main(args):
    parser = OptionParser()
    parser.add_option('--ui',
                      dest='ui',
                      default='console',
                      help="Sets the UI to use to greet the user. One of: %s" %
                      ", ".join("'%s'" % ui for ui in hello.list_uis()))
    parser.add_option('--lang',
                      dest='lang',
                      default='en',
                      help="Sets the language to use")
    options, args = parser.parse_args(args)
    if len(args) < 2:
        print "Sorry, I can't greet you if you don't say your name"
        return 1
    try:
        hello.greet(args[1], options.lang, options.ui)
    except hello.LanguageNotSupportedException:
        print "Sorry, I don't speak '%s'" % options.lang
        return 1
    except hello.UINotSupportedExeption:
        print "Invalid UI name\n"
        print "Valid UIs:\n\n" + "\n".join(' * ' + ui
                                           for ui in hello.list_uis())
        return 1
예제 #3
0
def testGreet():
    name = "World"
    expect = "Hello World!"
    result = greet(name)
    assert expect == result
    assert greet('John') == 'Hello John!'
    assert greet('Jen') == 'Hello Jen!'
    print('all test cases passed for greet()...')
예제 #4
0
파일: main.py 프로젝트: jython/book
def main(args):
    parser = OptionParser()
    parser.add_option('--ui', dest='ui', default='console', 
                      help="Sets the UI to use to greet the user. One of: %s" %
                      ", ".join("'%s'" % ui for ui in hello.list_uis()))
    parser.add_option('--lang', dest='lang', default='en',
                      help="Sets the language to use")
    options, args = parser.parse_args(args)
    if len(args) < 2:        
        print "Sorry, I can't greet you if you don't say your name"
        return 1    
    try:
        hello.greet(args[1], options.lang, options.ui)        
    except hello.LanguageNotSupportedException:
        print "Sorry, I don't speak '%s'" % options.lang
        return 1
    except hello.UINotSupportedExeption:
        print "Invalid UI name\n"    
        print "Valid UIs:\n\n" + "\n".join(' * ' + ui for ui in hello.list_uis())
        return 1
예제 #5
0
def test_1():
  name = "Normal Hello"
  input = "Bob"
  expected = "Hello Bob"
  actual = hello.greet(input)
  
  if actual == expected:
      status = "pass"
  else:
      status = "false"

  return printResults(name, input, status)
예제 #6
0
def test_2():
  name = "Empty Hello"
  input = ""
  expected = "Hello "
  actual = hello.greet(input)
  
  if actual == expected:
      status = "pass"
  else:
      status = "false"

  return printResults(name, input, status)
예제 #7
0
def test_1():
    name = "Normal Hello"
    input = "Bob"
    expected = "Hello Bob"
    actual = hello.greet(input)

    if actual == expected:
        status = "pass"
    else:
        status = "false"

    return printResults(name, input, status)
예제 #8
0
def test_2():
    name = "Empty Hello"
    input = ""
    expected = "Hello "
    actual = hello.greet(input)

    if actual == expected:
        status = "pass"
    else:
        status = "false"

    return printResults(name, input, status)
예제 #9
0
def test_2():
    name = "Empty Hello"
    input = ""
    expected = "Hello "
    actual = hello.greet(input)

    if actual == expected:
        marks = 2
        status = "pass"
    else:
        marks = 0
        status = "fail"

    return printResults(name, input, expected, actual, marks, status)
예제 #10
0
def test_1():
    name = "Normal Hello"
    input = "Bob"
    expected = "Hello Bob"
    actual = hello.greet(input)

    if actual == expected:
        marks = 1
        status = "pass"
    else:
        marks = 0
        status = "fail"

    return printResults(name, input, expected, actual, marks, status)
예제 #11
0
def test_1():
  name = "Normal Hello"
  input = "Bob"
  expected = "Hello Bob"
  actual = hello.greet(input)
  
  if actual == expected:
      marks = 1
      status = "pass"
  else:
      marks = 0
      status = "fail"

  return printResults(name, input, expected, actual, marks, status)
예제 #12
0
def test_2():
  name = "Empty Hello"
  input = ""
  expected = "Hello "
  actual = hello.greet(input)
  
  if actual == expected:
      marks = 2
      status = "pass"
  else:
      marks = 0
      status = "fail"

  return printResults(name, input, expected, actual, marks, status)
예제 #13
0
def test_greet_2():
    with raises(AttributeError):
        greet('')
"""
import sys, os


if __name__ == "__main__":

    dir_path = os.path.dirname(os.path.realpath(__file__))
    project_path = os.path.split(dir_path)[0]
    cpp_hello_world_code = os.path.join(project_path, 'src/core/cpp_build/HelloWorld')
    cpp_hello_box_code = os.path.join(project_path, 'src/core/cpp_build/HelloBox')

    sys.path.insert(0, cpp_hello_world_code)
    sys.path.insert(0, cpp_hello_box_code)

    import hello
    import hello_box

    print 'This "' + hello.greet() + '" is from a C++ piece of code, build in the folder \n' + cpp_hello_world_code

    my_box = hello_box.Box()

    my_box.height = 0.5
    my_box.width = 1.5
    my_box.length = 2.5

    my_box.file_path = os.path.join(project_path, 'data', 'box_info.txt')

    my_box.save_info()

    print "Check the file box_info.txt to see if everything works."
예제 #15
0
 def test_greet(self):
     self.assertEqual("Hello, Alice!", greet("Alice")) 
     self.assertEqual("Hello, Bob!", greet("Bob")) 
예제 #16
0
파일: testSTD.py 프로젝트: giulange/compss
def std_task(value):
    import hello
    hello.greet("FROM PYTHON TO C")
    return value + 1
예제 #17
0
import hello
print(hello.greet("good"))
from fib import fib
from hello import greet

print greet("Samarjit")
for i in range(5):
    print(fib(i))
예제 #19
0
def test_greet_1():
    assert greet('Mike') == 'Hello my dear Mike!'
예제 #20
0
import hello  #renamed module greetings as hello

hello.greet("bhalaji")

import greetings.greet as gr

gr.hello('bhalaji')
gr.bye('bhalaji')
예제 #21
0
import hello
from hello import greet as gr

def addNumbers(*numbers):
	total = 0
	for each in numbers:
		total += each
	
	return total	
	
	
print(addNumbers(1,2,3,4,5))
hello.greet()
gr()
예제 #22
0
def greet():
    print(hello.greet())
예제 #23
0
 def test_020_greet(self):
     self.assertEqual(greet('Alice'), 'Hello, Alice!', 'greet someone')
예제 #24
0
#!/usr/bin/env python

import hello

myname = "Joe"
myname = taint(myname)

ans1 = hello.greet(myname)

print(ans1)


def taint(val):
    return val
예제 #25
0
import hello

for x in range(3):
    print hello.greet(x)
예제 #26
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import hello
print(hello.greet())

예제 #27
0
import transmute

transmute.require([ 'hello' ], sources=[ 'dist' ])
transmute.update()

import hello
hello.greet()
예제 #28
0
 def testGreet(self):
     name = "World"
     expect = "Hello World!"
     result = hello.greet(name)
     self.assertEqual(expect, result)
예제 #29
0
 def test_030_greet_another(self):
     self.assertEqual(greet('Bob'), 'Hello, Bob!', 'greet someone else')
예제 #30
0
import sys
import transmute

transmute.require([ 'hello' ], sources=[ '../../hello/dist' ])
transmute.update()

import hello
hello.greet('test')
예제 #31
0
 def runTest(self):
     what = "World"
     greeting = hello.greet(what)
     self.assertEqual(greeting, "Hello, %s" % what)
예제 #32
0
# test.py
import hello
print(hello.greet("world"))
print("named:", hello.greet(name="world"))
예제 #33
0
#!/usr/bin/env python

import hello
print (hello.greet())

예제 #34
0
"""
测试打包是否成功
将build里的so文件移到同级目录下,将hell.py删除掉
运行python demo.py输出"hello Tom",说明调用的是so文件里的greet
"""

from hello import greet
print(greet("Tom"))
예제 #35
0
def test_hello():
    hello.inp = []
    hello.greet("Karole")
    assert hello.inp == ['Hello', 'Karole']
예제 #36
0
def test_hello_elena():
    hello.inp = []
    hello.greet("Elena")
    assert hello.inp == ['Hello', 'Elena']
예제 #37
0
#!/usr/bin/env python

import hello
print hello.greet()

예제 #38
0
#!/usr/bin/env python

# Use of hello module - Module Aliasing

from hello import SayHello as greet , SayBye as bye

greet('name')
bye()
예제 #39
0
파일: hello.py 프로젝트: sluo1989/computing
import hello
print hello.greet("World")
예제 #40
0
def test_greet(who):
    greeting = hello.greet(who)
    assert greeting == "{}, good evening!".format(who)