Skip to content

Joseph: Changes to tests.py #1

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 1 commit 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
43 changes: 31 additions & 12 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""--------------------------------------------------------------
Name: Joseph Cruz
Class: GIS 321

Assignment 1
--------------------------------------------------------------"""

import unittest

class Test_Assignment_01(unittest.TestCase):
Expand Down Expand Up @@ -35,55 +42,62 @@ def setUp(self):

def test_assert_truth(self):
"""
A test that will pass.
A test that will pass
"""
self.assertTrue(True)

def test_assert_truth_with_a_message(self):
"""
A test that will fail.
"""
self.assertFalse(True, 'This should fail, please fix it.')
#[Joseph] changed assertFalse to assertTrue
self.assertTrue(True, '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 = _
#[Joseph] expected value changed from _ to 2
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)
#[Joseph] changed to assertTrue and isinstance was added to check
#if True is of type bool
self.assertTrue(isinstance(True, bool))

def test_assert_string(self):
"""
A test for evaluating an expression
"""
my_string = 'Hello World'
my_string_length = len(my_string) # The expression
#[Joseph] -1 added to remove null at end of string
my_string_length = len(my_string)-1 # The expression
self.assertEqual(10, my_string_length)

def test_big_integers(self):
"""
A test to explore notation of big integers.
"""
x = 42,000
#[Joseph] removed comma in 42000
x = 42000
self.assertTrue(isinstance(x, int))

def test_bigger_integers(self):
"""
A test for bigger, or smaller integers
"""
big = 1e6
#[Joseph] changed big to 1e2 from 1e6
big = 1e2
self.assertEqual(big, 100)
self.assertTrue(type(big), int)

small = 1e-5
#[Joseph] changed small to 1e-4 from 1e-5
small = 1e-4
self.assertEqual(small, 0.0001)
self.assertTrue(type(small), int)

Expand All @@ -93,11 +107,14 @@ def test_type_conversion(self):
"""
i = 1
self.assertTrue(type(i) == int)
i= float(i)
self.assertTrue(isinstance(i, float)) # These lines do the same type checking
i = float(i)
self.assertTrue(isinstance(i, float))
i = str(i)
self.assertFalse(type(i), str)
#[Joseph] i=str(i) is commented out, removes the conversion
#and type() is changed to isinstance so assertFalse checks a bool
#i = str(i)
self.assertFalse(isinstance(i,str))

def test_type_conversion2(self):
"""
Expand All @@ -114,7 +131,9 @@ def test_type_conversion_gotcha(self):
"""
j = 3.9999
self.assertTrue(int(j), float)
self.assertEqual(int(j), 4)
#[Joseph] added 1 because of the rounding error in int. int concatenates
#a float to be an integer.
self.assertEqual(int(j)+1, 4)

def tearDown(self):
"""
Expand Down