Skip to content

Update tests.py #4

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

Open
wants to merge 2 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
24 changes: 12 additions & 12 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,61 +43,61 @@ def test_assert_truth_with_a_message(self):
"""
A test that will fail.
"""
self.assertFalse(True, 'This should fail, please fix it.')
self.assertFalse(False, 'This should fail, please fix it.')

def test_assert_equality(self):
"""
A test for equality by assigning a value to a variable
and evaluating an expression.
"""
expected_value = _
expected_value = 2
truth_value = 1 + 1
self.assertEqual(expected_value, truth_value)

def test_what_are_these_types(self):
"""
A test to know what the types of the previous fixes were
"""
self.assertFalse(True, bool)
self.assertFalse(False, bool)

def test_assert_string(self):
"""
A test for evaluating an expression
"""
my_string = 'Hello World'
my_string_length = len(my_string) # The expression
self.assertEqual(10, my_string_length)
self.assertEqual(11, my_string_length)

def test_big_integers(self):
"""
A test to explore notation of big integers.
"""
x = 42,000
x = 42000
self.assertTrue(isinstance(x, int))

def test_bigger_integers(self):
"""
A test for bigger, or smaller integers
"""
big = 1e6
self.assertEqual(big, 100)
self.assertTrue(type(big), int)
self.assertEqual(big, 1000000)
self.assertTrue(type(big), float)

small = 1e-5
self.assertEqual(small, 0.0001)
self.assertTrue(type(small), int)
self.assertEqual(small, 0.00001)
self.assertTrue(type(small), float)

def test_type_conversion(self):
"""
A series of tests to validate type conversion operations
"""
i = 1
self.assertTrue(type(i) == int)
self.assertTrue(isinstance(i, float)) # These lines do the same type checking
self.assertTrue(isinstance(i, int)) # These lines do the same type checking
i = float(i)
self.assertTrue(isinstance(i, float))
i = str(i)
self.assertFalse(type(i) == str)
self.assertFalse(type(i) == float)

def test_type_conversion2(self):
"""
Expand All @@ -114,7 +114,7 @@ def test_type_conversion_gotcha(self):
"""
j = 3.9999
self.assertTrue(int(j), float)
self.assertEqual(int(j), 4)
self.assertEqual(int(j), 3)

def tearDown(self):
"""
Expand Down