def test_add_single_number():
    """ passing in a single number as a string should result in an integer"""
    result = add("5")
    assert result == 5

    result = add("0")
    assert result == 0

    result = add("555")
    assert result == 555
def test_add_multiple_numbers():
    result = add("1,2")
    assert result == 3

    result = add("5,7")
    assert result == 12

    result = add("5,7,100")
    assert result == 112

    result = add("5,7,2000")
    assert result == 2012
Example #3
0
##  This is our main program.

# Start with import statements
import stuff

print(stuff.pi)
print(stuff.add(4, 15))

## Standard libraries

## Pseudorandom number time since 1970-01-01
import random

random.randint(3, 486)
myList = ["heky", "cheeta", "cougar", "plant"]
random.choice(myList)
myList
random.shuffle(myList)
myList

## math module
import math
math.pi
math.e
math.sqrt(40)
round(math.sqrt(40), 3)

import webbrowser
webbrowser.open("http://www.google.com")

## only pi is imported
Example #4
0
 def test_add(self):
     self.assertEqual(add(self.a, self.b), self.aplusb)
def test_works_with_newline():
    result = add("1\n2")
    assert result == 3

    result = add("1\n2,3")
    assert result == 6
def test_add_returns_0_for_empty_strings():
    result = add("")
    assert result == 0
##  This is our main program.

# Start with import statements
import stuff

print(stuff.pi)
print(stuff.add(4,15))


## Standard libraries

## Pseudorandom number time since 1970-01-01
import random

random.randint(3,486)
myList = ["heky","cheeta","cougar","plant"]
random.choice(myList)
myList
random.shuffle(myList)
myList


## math module
import math
math.pi
math.e
math.sqrt(40)
round(math.sqrt(40), 3 )


import webbrowser