Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Commit #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ def test_none_is_universal(self):
"""
Think about what 'is' does here.
"""
truth = ____
truth = True
self.assertEqual(truth, None is None)

def test_none_is_unique(self):
"""
This is a great place to launch an interpreter and check
what the tight hand side of the equalities evaluate to.
"""
truth = ____
truth = True
self.assertEqual(truth, None is not 0)
truth = ____ # This resets the value of truth
truth = True # This resets the value of truth
self.assertEqual(truth, None is not False)

def test_none_existence(self):
Expand All @@ -28,7 +28,7 @@ def test_none_existence(self):
checker = None
if checker:
x = 1
self.assertEqual(1,x)
self.assertEqual(0,x)

def test_truthiness(self):
"""
Expand All @@ -38,9 +38,9 @@ def test_truthiness(self):
y = 0
if not x:
y = 1
self.assertEqual(0, y)
self.assertEqual(1, y)

self.assertTrue(x == None) # Not PEP8 compliant, but commonly used.
self.assertFalse(x == None) # Not PEP8 compliant, but commonly used.

"""
The take away here is that truthiness is not the same as None
Expand All @@ -66,16 +66,16 @@ def test_quotations(self):
"""

string = 'Hello World'
self.assertEqual(____, isinstance(string, str))
self.assertEqual(True, isinstance(string, str))

string = "Hello World"
self.assertEqual(____, isinstance(string, str))
self.assertEqual(True, isinstance(string, str))

string = '''Hello World'''
self.assertEqual(____, isinstance(string, str))
self.assertEqual(True, isinstance(string, str))

string = """Hello World"""
self.assertEqual(____, isinstance(string, str))
self.assertEqual(True, isinstance(string, str))

def test_escaping_quotes(self):
"""
Expand All @@ -87,18 +87,18 @@ def test_escaping_quotes(self):
a = "He said, \"Don't forget to relax a little\""
b = 'He said, "Don\'t" forget to relax a little'

self.assertEqual(____, a == b)
self.assertEqual(False, a == b)

def test_string_concatenation(self):
"""
Concatenation is either explicit or implicit.
See the Zen of Python for which is preferable
"""
string = "Go" + " Sun Devils"
self.assertEqual(____, string)
self.assertEqual('Go Sun Devils', string)

string = "Go" " Sun Devils"
self.assertEqual(____, string)
self.assertEqual('Go Sun Devils', string)

def test_in(self):
"""
Expand All @@ -111,10 +111,10 @@ def test_in(self):
For these, fix the assertion methods
"""
cities = '"New York", "Boston", "Chicago", "Dallas", "St. Louis", "Phoenix" '
self.assert____('Dallas' in cities)
self.assert____('"Dallas"' in cities)
self.assert____('ton' in cities)
self.assert____("\", \"" in cities)
self.assertTrue('Dallas' in cities)
self.assertTrue('"Dallas"' in cities)
self.assertTrue('ton' in cities)
self.assertTrue("\", \"" in cities)

def test_format(self):
"""
Expand All @@ -124,23 +124,23 @@ def test_format(self):
"""

s = 'The current index is {}'
self.assertEqual(____,isinstance(s, str))
self.assertEqual(True,isinstance(s, str))

i = 0

truth = 'The current index is _____' # Replace the ____
truth = 'The current index is 0' # Replace the ____
self.assertEqual(truth, s.format(i))

def test_string_cases(self):
"""
Another common string manipulation set borrowed from
Python Koans.
"""
self.assertEqual(__, 'guido'.capitalize())
self.assertEqual(__, 'guido'.upper())
self.assertEqual(__, 'TimBot'.lower())
self.assertEqual(__, 'guido van rossum'.title())
self.assertEqual(__, 'ToTaLlY aWeSoMe'.swapcase())
self.assertEqual('Guido', 'guido'.capitalize())
self.assertEqual('GUIDO', 'guido'.upper())
self.assertEqual('timbot', 'TimBot'.lower())
self.assertEqual('Guido Van Rossum', 'guido van rossum'.title())
self.assertEqual('tOtAlLy AwEsOmE', 'ToTaLlY aWeSoMe'.swapcase())

def test_format_rounding(self):
"""
Expand All @@ -156,9 +156,9 @@ def test_format_rounding(self):
s = '{}'

# Check to see what the heck 's' is
self.assertEqual(____, isinstance(s, str))
self.assertEqual(True, isinstance(s, str))

rounded_pi = _________
rounded_pi = '3.1416'
self.assertEqual(rounded_pi, s.format(round(pi, 4)))

def test_translation(self):
Expand All @@ -177,7 +177,7 @@ def test_translation(self):
s = 'The quick brown fox jumped over the lazy dog.'
s.translate(leet) # Translate the string here

truth = ____ # Truth is the newly translated string
truth = 'The quick brown fox jumped over the lazy dog.' # Truth is the newly translated string

self.assertEqual(truth, s)

Expand All @@ -186,7 +186,9 @@ def test_write_your_own(self):
Write your own test here demonstrating either string
or None usage that has not been demonstrated above.
"""
self.assertTrue(False) # You can either fix this line or remove it once the test is in.
name = 'Mohommad'
truth = (name.replace('hom','1234')=='Mo1234mad')
self.assertTrue(truth) # You can either fix this line or remove it once the test is in.

def tearDown(self):
pass