d?U)0OgmTaS8ql!Ne
z=G-}^uUw!8?0j{r()$Fc3}a|2BL6~*jc_2mA@1HxGbRbtCl0<~tKy#~Qx%zp-m2n@
zL)?C^8EX)z??7!){L^J>0w`FAKg1=xrtfiqy5ivVtxE3{nUXS%0;sA9aT`I20`(=R
zElRIjrfviURh1!5gN6?X)UbnZ2rK?%nd+|4UZN1WEW@a7QSpv2_aUrira;YxgrfN2
zsJKDxQt{guac`C0)Dd@o>@j10fjUP^{dsKjAMO0m3rg>kMB2q-t*%n0e)1Y!d5C=E
z;4Y>28zPMs;dpm(Z1V(}n&uLZr<+|f+2&jTMm(NrcBQh-6#!20xYz7*u+0wv(BknN
zlMZNgDKhm|-2FqkNiWdq@@1+CAk(BvwYn;qLI7TqF4F2&%akqdrllnj1wXh;?R`J)
zzUbHMej!k6v&=3JOCDvUB^wp|M?0TetTmMpX_L~8SfNafr^WspnR+M8H9V*K>jcW}
zHLJHMc)gv!Cd-H|1r_3kl2CI|+}*fU^*aUX-gL7%sNi=w_=;@9H(sV(VNTzm_GSsx
z{w%YgNx^^T;3t5Bwd0^#)LxH3B|t${kAs)8jhJ1g(!yN92GySh)@GOWeJ;SpQ&1!Ta7>LoLXNMXc3&z2JA9w$~
zNp(Sk8aw|7fUxQ+*P1@F^N#{-R$V1v96SrKLv_&sN+VKoLj2TT&USvUD5(Z42neC
zV{v!?&8XuVmTY`MUHrU)cL(&DNV9c1rB_{I@Ep;$FYZ>8QT^_Ki~tIK|*jqOBJad1!zJRjH3`
zR`3sV%$vOiwu+Xng)3TP=N}JqvAc=3)iC82`6T>Wy0XzgK1(jyu8K!KgKyW!tqM-i
ziTA>sZyf4V6#OeXQ3)^!^=$%hCf*BizHHPN0$>vG2=L88eek3D%9Vg8OBab!vJLDq
zou~$wj8d`yoQVQ}9Fzjvf0;?p05_o&kAc}Qor$}Hrz-XBQ1er|*}{m}txRHUn8TJk
zE(zeCBG#n~R4h|IYG=v*RJ0r>4Y^Q$K(oy)(#OLMZ)FlML$HwOfpgiPi}Fh~TjP3l
zGR*2;ptsN>)=4MEK;m^`-3=_MjzzoYYqk|7dX7`X?q(7WP#+WP3P6!)Iw-S5CqX^Q
zB;Xkk{G8}1WXW0r4T73dqR#_W$|NXIeCtaPAPHo|^nFo?Bxc`I&D-Vpf
zV8!be>^tDF;Gq@^&YpQT&%nO*@Fq0K6GkEH1`8fJBU@(1EDJh?QOM1(;QTggPV5Yt
zEMgZQ_|$6iQ}llQ9XEFCJ$Vqo`mUcSv1IV_HfvDqzJ)}MX6rxn&(ZwSvsT`{c#ai(
zck2Wz!F_FYZ&zk~OljV>I!>smqryf18R0TMl1srm#fLf8I8O|Lt}3|ABwMmj93U
bq5o=K{)~AC5A{3^|1hxfl0b21QLX$h)3d4-
literal 0
HcmV?d00001
diff --git a/students/douglas_klos/session9/examples/test_object_canvas.py b/students/douglas_klos/session9/examples/test_object_canvas.py
new file mode 100755
index 00000000..f88a58c6
--- /dev/null
+++ b/students/douglas_klos/session9/examples/test_object_canvas.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+
+"""
+test code for the object_canvas
+
+Note: Testing image generation is hard. So for now, this mostly just
+ tests that the rendering function runs.
+ And during development, you can look at the resulting files.
+
+ One could store "properly" rendered results for future tests to
+ check against.
+"""
+
+# import os
+import pathlib
+import object_canvas as oc
+
+SAVE_ALL=True # save all the temp files?
+
+
+def render_to_file(canvas, filename="test_image.png", save=False):
+ """
+ utility to render a canvas to a file
+
+ :param filename: name of file to render to it will be put in a test_images dir.
+
+ :param remove=True: whether to remove the file after rendering.
+ """
+ path = pathlib.Path("test_images")
+ path.mkdir(exist_ok=True)
+ path /= filename
+ canvas.render(str(path))
+ assert path.is_file()
+ if not (SAVE_ALL or save):
+ path.unlink()
+
+
+def test_init():
+ canvas = oc.ObjectCanvas()
+
+ assert canvas
+
+def test_backgound():
+ canvas = oc.ObjectCanvas(background='blue')
+ render_to_file(canvas, "blue_background.png")
+
+def test_polyline():
+ """
+ can we draw a polyline?
+ """
+ canvas = oc.ObjectCanvas()
+ points = ((10, 10), # this should be a triangle
+ (10, 400),
+ (400, 10),
+ (10, 10),
+ )
+
+ pl = oc.PolyLine(points)
+ canvas.add_object(pl)
+ render_to_file(canvas, "polyline.png")
+
+
+def test_circle():
+ canvas = oc.ObjectCanvas()
+ center = (100, 100)
+ diameter = 75
+ for line_width in range(1, 5):
+ c = oc.Circle(center,
+ diameter,
+ line_color="red",
+ fill_color="blue",
+ line_width=line_width,
+ )
+ canvas.add_object(c)
+ center = (center[0] + 50, center[0] + 50)
+ render_to_file(canvas, "circle.png")
+
From de7bc9fd7caac7191d3712fa757563a6d77dc0a0 Mon Sep 17 00:00:00 2001
From: Jeff Shabani
Date: Wed, 6 Mar 2019 14:27:38 -0800
Subject: [PATCH 076/354] Circle update
---
students/jeff_shabani/session08/Circle.py | 33 +++++++++----------
.../jeff_shabani/session08/test_circle.py | 8 ++++-
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/students/jeff_shabani/session08/Circle.py b/students/jeff_shabani/session08/Circle.py
index 284d3526..a8de1765 100644
--- a/students/jeff_shabani/session08/Circle.py
+++ b/students/jeff_shabani/session08/Circle.py
@@ -6,9 +6,19 @@ class Circle(object):
instances = []
def __init__(self, radius):
- self.radius = radius
+ self._radius = radius
Circle.instances.append(self)
+ @property
+ def radius(self):
+ return self._radius
+
+ @radius.setter
+ def radius(self, val):
+ if val < 0:
+ raise ValueError('Radius cannot be less than zero')
+ self._radius = val
+
@property
def diameter(self):
return self.radius * 2
@@ -62,10 +72,10 @@ def __str__(self):
class Sphere(Circle):
def volume(self):
- return (4/3)*math.pi*(self.radius**3)
+ return (4 / 3) * math.pi * (self.radius ** 3)
def area(self):
- return 4 * math.pi * (self.radius**2)
+ return 4 * math.pi * (self.radius ** 2)
def __repr__(self):
return f'Sphere with radius of {self.radius} volume of {self.volume()} & surface area of {self.area()}'
@@ -74,18 +84,7 @@ def __str__(self):
return f'Sphere with radius of {self.radius} volume of {self.volume()} & surface area of {self.area()}'
-
if __name__ == '__main__':
-
- c1 = Circle(1)
- c2 = Circle(5)
- c3 = Circle(3)
- c4 = Circle(4)
- c5 = Circle(2)
- s=Sphere(10)
- sfd = Sphere.from_diameter(4)
- print(s)
-
-
-
-
+ c1 = Circle(-11)
+ c1.radius = -1
+ print(c1)
diff --git a/students/jeff_shabani/session08/test_circle.py b/students/jeff_shabani/session08/test_circle.py
index df995f61..2a608ac1 100644
--- a/students/jeff_shabani/session08/test_circle.py
+++ b/students/jeff_shabani/session08/test_circle.py
@@ -70,6 +70,13 @@ def test_extended_assignment(self):
c3 = c1.radius ** 2
self.assertEqual(c2, 22)
self.assertEqual(c3, 144)
+ del c1, c2, c3
+
+ @unittest.expectedFailure
+ def test_negative_radius(self):
+ c1 = Circle(2)
+ c1.radius = -1
+ self.assertEqual(c1, -1)
def test_sphere_volume(self):
s = Sphere(1)
@@ -87,6 +94,5 @@ def test_spehere_printing(self):
-
if __name__ == '__main__':
unittest.main()
From e7865bc9085aceb7833c0e7bc9fdccd773eff31b Mon Sep 17 00:00:00 2001
From: Jeff Shabani
Date: Wed, 6 Mar 2019 14:29:46 -0800
Subject: [PATCH 077/354] Circle test update
---
students/jeff_shabani/session08/test_circle.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/students/jeff_shabani/session08/test_circle.py b/students/jeff_shabani/session08/test_circle.py
index 2a608ac1..f9319795 100644
--- a/students/jeff_shabani/session08/test_circle.py
+++ b/students/jeff_shabani/session08/test_circle.py
@@ -72,6 +72,7 @@ def test_extended_assignment(self):
self.assertEqual(c3, 144)
del c1, c2, c3
+ #test for negative radius
@unittest.expectedFailure
def test_negative_radius(self):
c1 = Circle(2)
From 05ae8033c15042f1bfed3e85d1c37e8e1e221041 Mon Sep 17 00:00:00 2001
From: Rockwell70
Date: Wed, 6 Mar 2019 15:41:17 -0800
Subject: [PATCH 078/354] Circle update
---
students/jeff_shabani/session08/Circle.py | 18 ++++++------------
students/jeff_shabani/session08/test_circle.py | 4 ++--
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/students/jeff_shabani/session08/Circle.py b/students/jeff_shabani/session08/Circle.py
index a8de1765..5ba832e6 100644
--- a/students/jeff_shabani/session08/Circle.py
+++ b/students/jeff_shabani/session08/Circle.py
@@ -6,19 +6,13 @@ class Circle(object):
instances = []
def __init__(self, radius):
+ if radius < 0:
+ raise ValueError('Radius cannot be less than zero')
+ else:
+ self.radius = radius
self._radius = radius
Circle.instances.append(self)
- @property
- def radius(self):
- return self._radius
-
- @radius.setter
- def radius(self, val):
- if val < 0:
- raise ValueError('Radius cannot be less than zero')
- self._radius = val
-
@property
def diameter(self):
return self.radius * 2
@@ -85,6 +79,6 @@ def __str__(self):
if __name__ == '__main__':
- c1 = Circle(-11)
- c1.radius = -1
+ c1 = Circle(1)
+ # c1.radius = -1
print(c1)
diff --git a/students/jeff_shabani/session08/test_circle.py b/students/jeff_shabani/session08/test_circle.py
index f9319795..7925fde2 100644
--- a/students/jeff_shabani/session08/test_circle.py
+++ b/students/jeff_shabani/session08/test_circle.py
@@ -75,9 +75,9 @@ def test_extended_assignment(self):
#test for negative radius
@unittest.expectedFailure
def test_negative_radius(self):
- c1 = Circle(2)
- c1.radius = -1
+ c1 = Circle(-1)
self.assertEqual(c1, -1)
+ del c1
def test_sphere_volume(self):
s = Sphere(1)
From 179fe8aecce14ebd2a9c08d27452afaa65614c58 Mon Sep 17 00:00:00 2001
From: Douglas Klos
Date: Wed, 6 Mar 2019 16:44:40 -0800
Subject: [PATCH 079/354] rot13 function working
---
.../douglas_klos/extra/numerals/numerals.py | 3 ++-
students/douglas_klos/extra/rot13/rot13.py | 27 +++++++++++++++++++
.../douglas_klos/extra/rot13/test_rot13.py | 20 ++++++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)
create mode 100755 students/douglas_klos/extra/rot13/rot13.py
create mode 100755 students/douglas_klos/extra/rot13/test_rot13.py
diff --git a/students/douglas_klos/extra/numerals/numerals.py b/students/douglas_klos/extra/numerals/numerals.py
index 6ddc344d..49b23912 100755
--- a/students/douglas_klos/extra/numerals/numerals.py
+++ b/students/douglas_klos/extra/numerals/numerals.py
@@ -45,7 +45,8 @@ def convert_to_arabic(self, value):
return_arabic -= self.ROMAN_NUMERAL_LIST[value[i]]
else:
return_arabic += self.ROMAN_NUMERAL_LIST[value[i]]
- self.arabic = return_arabic + self.ROMAN_NUMERAL_LIST[value[-1]]
+
+ self.arabic = return_arabic + self.ROMAN_NUMERAL_LIST[value[-1]]
if self.arabic < 5000:
return self.arabic
raise ValueError
diff --git a/students/douglas_klos/extra/rot13/rot13.py b/students/douglas_klos/extra/rot13/rot13.py
new file mode 100755
index 00000000..9cb11bb1
--- /dev/null
+++ b/students/douglas_klos/extra/rot13/rot13.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+""" Class to convert rot13 'encrypt' """
+
+# Douglas Klos
+# March 6th, 2019
+# Python 210, Session 8
+# rot13.py
+
+# a - z == 97 - 122
+# A - Z == 65 - 90
+# We'll ignore other characters such as punctuation
+
+
+def rot13(value):
+ """ Function to perform rot13 on input """
+
+ output = ''
+ for letter in value:
+ if ord(letter) >= 97 and ord(letter) <= 122:
+ output += chr(ord(letter) - 13) if ord(letter) >= 110 else chr(ord(letter) + 13)
+ elif ord(letter) >= 65 and ord(letter) <= 90:
+ output += chr(ord(letter) - 13) if ord(letter) >= 78 else chr(ord(letter) + 13)
+ else:
+ output += letter
+ print(output)
+ return output
diff --git a/students/douglas_klos/extra/rot13/test_rot13.py b/students/douglas_klos/extra/rot13/test_rot13.py
new file mode 100755
index 00000000..d0e9fbde
--- /dev/null
+++ b/students/douglas_klos/extra/rot13/test_rot13.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+""" Test cases for rot13.py """
+
+# Douglas Klos
+# March 6th, 2019
+# Python 210, Session 8
+# test_rot13.py
+
+import rot13
+
+
+def test_rot13():
+ """ Basic test cases for rot13 """
+ assert rot13.rot13('abcdefghijklm') == 'nopqrstuvwxyz'
+ assert rot13.rot13('nopqrstuvwxyz') == 'abcdefghijklm'
+ assert rot13.rot13('abcdefghijklm'.upper()) == 'nopqrstuvwxyz'.upper()
+ assert rot13.rot13('nopqrstuvwxyz'.upper()) == 'abcdefghijklm'.upper()
+
+ assert rot13.rot13(rot13.rot13('This is a test')) == 'This is a test'
From 72460c2f4e1fb36f115bc44ab53ad8e78462ac4e Mon Sep 17 00:00:00 2001
From: UncleanlyCleric
Date: Wed, 6 Mar 2019 19:26:51 -0800
Subject: [PATCH 080/354] Small problem with rmul
---
students/jesse_miller/session08/circle.py | 29 +++++-
.../jesse_miller/session08/test_circle.py | 88 ++++++++++++++++---
2 files changed, 105 insertions(+), 12 deletions(-)
diff --git a/students/jesse_miller/session08/circle.py b/students/jesse_miller/session08/circle.py
index c01ae371..787e2df1 100644
--- a/students/jesse_miller/session08/circle.py
+++ b/students/jesse_miller/session08/circle.py
@@ -8,11 +8,12 @@
Imported the math module for calculation
'''
-class Circle(object):
+class Circle():
'''
Defining the circle class
'''
def __init__(self, radius):
+
self.radius = radius
@property
@@ -35,3 +36,29 @@ def area(self):
Defining area, I'm a tad more confident in this one
'''
return pi * self.radius**2
+
+ @classmethod
+ def from_diameter(cls, value):
+ '''
+ Attempting to do step five from the assignment, create a circle from
+ entering the diameter, not the radius.
+ '''
+ return cls(value/2)
+
+ def __str__(self):
+ return f'{self.__class__.__name__} with radius: {self.radius}'
+
+ def __repr__(self):
+ return f'{self.__class__.__name__}({self.radius})'
+
+ def __add__(self, other):
+ return Circle(self.radius + other.radius)
+
+ def __rmul__(self, value):
+ return Circle(self.radius * value)
+
+ def __mul__(self, value):
+ try:
+ return Circle(self.radius * value)
+ except TypeError:
+ rmul(self, value)
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index a2a955ff..79e680a2 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -1,35 +1,56 @@
-# Tests for Circle Class
-
-import pytest
+'''
+Tests for Circle program
+You'll note that this is chock full of pylint disables. This is because I use
+Atom's pylinter plugin, and while it's fantastic at helping me with problems
+while I'm going, unit testing is going to have linting problems, so I disable
+them as they come up, that way I know when I'm doing something bad.
+'''
from math import pi
+import pytest
from circle import Circle
-# Step 1
-def test_empty():
+def test_empty_circle():
+ '''
+ Test 1: No values insertered.
+ '''
+ #pylint: disable=E1120
with pytest.raises(TypeError):
Circle()
-def test_new():
+def test_new_circle():
+ '''
+ Test 2: Testing a value for the circle.
+ '''
Circle(1)
def test_radius():
+ '''
+ Test 3: Testing inserting a radius.
+ '''
+ #pylint: disable=C0103
c = Circle(2)
assert c.radius == 2
-# Step 2
def test_diameter():
+ '''
+ Test 4: Testing diameter calculation.
+ '''
+ #pylint: disable=C0103
c = Circle(3)
assert c.diameter == 6
-# Step 3
-def test_diameter_set():
+def test_set_diameter():
+ '''
+ Test 5: Testing manually setting a diameter.
+ '''
+ #pylint: disable=C0103
c = Circle(4)
c.diameter = 5
@@ -37,15 +58,60 @@ def test_diameter_set():
assert c.radius == 2.5
-# Step 4
def test_area():
+ '''
+ Test 6: Testing area calculation.
+ '''
+ #pylint: disable=C0103
c = Circle(6)
assert c.area == pi * 36
-def test_area_set():
+def test_set_area():
+ '''
+ Test 7: Testing AttributeError
+ '''
+ #pylint: disable=C0103
c = Circle(7)
with pytest.raises(AttributeError):
c.area = 10
+
+
+def test_from_diameter():
+ '''
+ Test 8: Testing calculating circle from diameter insertion
+ '''
+ #pylint: disable=C0103
+ c = Circle.from_diameter(8)
+
+ assert c.diameter == 8
+ assert c.radius == 4
+
+
+def test_string():
+ '''
+ Test 9: String insertion and formatted print
+ '''
+ #pylint: disable=C0103
+ c = Circle(9)
+ assert str(c) == "Circle with radius: 9"
+
+def test_string_representation():
+ '''
+ Test 10: Testing string representation, turns out it's a lot like string
+ '''
+ #pylint: disable=C0103
+ c = Circle(12)
+ assert repr(c) == "Circle(12)"
+
+def test_add_circles():
+ '''
+ Test 11: Testing adding circles
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(4)
+ c2 = Circle(6)
+
+ assert c1 + c2 == Circle(10)
From 16278c55bbc3d37edc87afc00c0c77714ef18a50 Mon Sep 17 00:00:00 2001
From: Douglas Klos
Date: Wed, 6 Mar 2019 20:52:45 -0800
Subject: [PATCH 081/354] fun with lambda
---
.../extra/lambda/lambda_keyword.py | 42 +++++++++++++++++++
.../douglas_klos/extra/lambda/test_lambda.py | 17 ++++----
2 files changed, 49 insertions(+), 10 deletions(-)
create mode 100755 students/douglas_klos/extra/lambda/lambda_keyword.py
mode change 100644 => 100755 students/douglas_klos/extra/lambda/test_lambda.py
diff --git a/students/douglas_klos/extra/lambda/lambda_keyword.py b/students/douglas_klos/extra/lambda/lambda_keyword.py
new file mode 100755
index 00000000..1b20ee6b
--- /dev/null
+++ b/students/douglas_klos/extra/lambda/lambda_keyword.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+# Douglas Klos
+# March 6th, 2019
+# Python 210, Session 8
+# lambda_keyword.py
+
+
+def function_builder(value):
+
+ # This is the working line with list comprehension
+ # return [(lambda y: (lambda x: y + x))(i) for i in (range(value))]
+
+ # This is the working multiline
+ return_list = []
+ for i in range(value):
+ return_list.append((lambda y: (lambda x: y + x))(i))
+ return return_list
+
+ # These were the failures that look like they should work
+
+ # return_list = []
+ # for i in range(value):
+ # print(i)
+ # return_list.append(lambda x: x + i)
+ # return return_list
+
+ # return [lambda x: x+i for i in range(value)]
+
+
+def main():
+
+ func_list = function_builder(10)
+
+ print(func_list[0](0))
+ print(func_list[1](0))
+ print(func_list[2](0))
+ print(func_list[3](0))
+ print(func_list[4](0))
+
+if __name__ == '__main__':
+ main()
\ No newline at end of file
diff --git a/students/douglas_klos/extra/lambda/test_lambda.py b/students/douglas_klos/extra/lambda/test_lambda.py
old mode 100644
new mode 100755
index 4992afd3..0d4789e1
--- a/students/douglas_klos/extra/lambda/test_lambda.py
+++ b/students/douglas_klos/extra/lambda/test_lambda.py
@@ -1,3 +1,10 @@
+#!/usr/bin/env python3
+
+# Douglas Klos
+# March 6th, 2019
+# Python 210, Session 8
+# lambda_keyword.py
+
"""
Some simple tests for the "lambda and keyword magic"
function builder
@@ -6,8 +13,6 @@
"""
from lambda_keyword import function_builder
-# uncomment to test second version
-# from lambda_keyword import function_builder2 as function_builder
def test_length():
@@ -15,9 +20,7 @@ def test_length():
the function should return a list of the length input
"""
assert len(function_builder(0)) == 0
-
assert len(function_builder(3)) == 3
-
assert len(function_builder(5)) == 5
@@ -28,11 +31,8 @@ def test_increment():
func_list = function_builder(5)
assert func_list[0](3) == 3
-
assert func_list[1](3) == 4
-
assert func_list[2](3) == 5
-
assert func_list[3](3) == 6
@@ -40,11 +40,8 @@ def test_increment2():
"""
the functions in the list should increment the input values
"""
-
func_list = function_builder(10)
assert func_list[0](12) == 12
-
assert func_list[1](10) == 11
-
assert func_list[9](3) == 12
From d459f6bbdf292d4bd582f0578e627f59489dca8d Mon Sep 17 00:00:00 2001
From: admin <23247076+Rockwell70@users.noreply.github.com>
Date: Thu, 7 Mar 2019 06:01:13 -0800
Subject: [PATCH 082/354] circle class
---
students/jeff_shabani/session08/Circle.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/students/jeff_shabani/session08/Circle.py b/students/jeff_shabani/session08/Circle.py
index 5ba832e6..98dfa0d6 100644
--- a/students/jeff_shabani/session08/Circle.py
+++ b/students/jeff_shabani/session08/Circle.py
@@ -1,6 +1,12 @@
#!/usr/bin/env python3
import math
+"""
+Framework for a circular object.
+Validation prevents user from entering a
+negative radius value.
+"""
+
class Circle(object):
instances = []
@@ -42,6 +48,7 @@ def __ipow__(self, other):
def __mul__(self, other):
return self.radius * other
+ #allow for reversal of arguments
__rmul__ = __mul__
def __lt__(self, other):
From dc540f19eb45aba208a6beab01b265cde87097d3 Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 07:56:47 -0800
Subject: [PATCH 083/354] Working through the rest of the circle. I'll start
on sphere before I submit
---
students/jesse_miller/session08/circle.py | 30 ++++++++-
.../jesse_miller/session08/test_circle.py | 66 ++++++++++++++++++-
2 files changed, 91 insertions(+), 5 deletions(-)
diff --git a/students/jesse_miller/session08/circle.py b/students/jesse_miller/session08/circle.py
index 787e2df1..1ae91f9e 100644
--- a/students/jesse_miller/session08/circle.py
+++ b/students/jesse_miller/session08/circle.py
@@ -52,13 +52,37 @@ def __repr__(self):
return f'{self.__class__.__name__}({self.radius})'
def __add__(self, other):
- return Circle(self.radius + other.radius)
+ return self.radius + other.radius
def __rmul__(self, value):
- return Circle(self.radius * value)
+ return self.radius * value
def __mul__(self, value):
try:
- return Circle(self.radius * value)
+ return self.radius * value
except TypeError:
+ #pylint: disable=E0602
+ '''
+ I have no idea why this works, but is getting a linter error over
+ unassigned variables.
+ '''
rmul(self, value)
+
+ def __lt__(self, other):
+ if self.radius < other.radius:
+ return True
+ return False
+
+ def __gt__(self, other):
+ if self.radius > other.radius:
+ return True
+ return False
+
+ def __eq__(self, other):
+ pass
+
+ def sort_var(self):
+ '''
+ This one wants a doc string for sorting, so this method sorts
+ '''
+ return self.radius
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index 79e680a2..d014d49c 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -111,7 +111,69 @@ def test_add_circles():
Test 11: Testing adding circles
'''
#pylint: disable=C0103
+ c1 = Circle(6)
+ c2 = Circle(4)
+
+ assert c1 + c2 == 10
+
+def test_multiply_circles():
+ '''
+ Test 12: Testing multiplication
+ '''
+ #pylint: disable=C0103
c1 = Circle(4)
- c2 = Circle(6)
+ c2 = Circle(2)
+
+ assert c1 * c2 == 8
+
+def test_rmul_circles():
+ '''
+ Test 13: Testing the rmul function
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(2)
+
+ assert 4 * c1 == 8
+
+def test_greater_than():
+ '''
+ Test 14: Testing greater than
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(2)
+ c2 = Circle(5)
+
+ assert (c1 > c2) is False
+
+
+def test_less_than():
+ '''
+ Test 15: Less than
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(2)
+ c2 = Circle(5)
+
+ assert (c1 < c2) is True
+
+
+def test_equal_to():
+ '''
+ Testing equal to function
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(3)
+ c2 = Circle(3)
+
+ assert (c1 == c2) is True
+
+
+def test_sort():
+ '''
+ Testing the sorting function
+ '''
+ #pylint: disable=C0103
+ circles = [Circle(4), Circle(1), Circle(3), Circle(2), Circle(5)]
+ circles.sort()
- assert c1 + c2 == Circle(10)
+ assert circles == [Circle(1), Circle(2), Circle(3), Circle(4), Circle(5)]
From d6760f754083d3773f6405726181e1f9dd01e9af Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 07:57:42 -0800
Subject: [PATCH 084/354] Sorting is going to be a thing, I can tell already
---
students/jesse_miller/session08/circle.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/students/jesse_miller/session08/circle.py b/students/jesse_miller/session08/circle.py
index 1ae91f9e..09cf2577 100644
--- a/students/jesse_miller/session08/circle.py
+++ b/students/jesse_miller/session08/circle.py
@@ -74,12 +74,14 @@ def __lt__(self, other):
return False
def __gt__(self, other):
- if self.radius > other.radius:
+ if self.radius < other.radius:
return True
return False
def __eq__(self, other):
- pass
+ if self.radius == other.radius:
+ return True
+ return False
def sort_var(self):
'''
From 01dccd8267d638f2decc34677f38e9b55f3ca4de Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 08:18:06 -0800
Subject: [PATCH 085/354] Well, I learned that what I would expect to be div,
is actually truediv.
---
students/jesse_miller/session08/circle.py | 18 ++++++++++++
.../jesse_miller/session08/test_circle.py | 28 ++++++++++++++++---
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/students/jesse_miller/session08/circle.py b/students/jesse_miller/session08/circle.py
index 09cf2577..e8657e00 100644
--- a/students/jesse_miller/session08/circle.py
+++ b/students/jesse_miller/session08/circle.py
@@ -68,6 +68,20 @@ def __mul__(self, value):
'''
rmul(self, value)
+ def __rtruediv__(self, value):
+ return self.radius / value
+
+ def __truediv__(self, value):
+ try:
+ return self.radius / value
+ except TypeError:
+ #pylint: disable=E0602
+ '''
+ I have no idea why this works, but is getting a linter error over
+ unassigned variables.
+ '''
+ rdiv(self, value)
+
def __lt__(self, other):
if self.radius < other.radius:
return True
@@ -88,3 +102,7 @@ def sort_var(self):
This one wants a doc string for sorting, so this method sorts
'''
return self.radius
+
+ @staticmethod
+ def __sort__(circle_list):
+ return circle_list.sort(key=Circle.sort_var)
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index d014d49c..19dd48a5 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -140,8 +140,8 @@ def test_greater_than():
Test 14: Testing greater than
'''
#pylint: disable=C0103
- c1 = Circle(2)
- c2 = Circle(5)
+ c1 = Circle(5)
+ c2 = Circle(2)
assert (c1 > c2) is False
@@ -159,7 +159,7 @@ def test_less_than():
def test_equal_to():
'''
- Testing equal to function
+ Test 16: Testing equal to function
'''
#pylint: disable=C0103
c1 = Circle(3)
@@ -170,10 +170,30 @@ def test_equal_to():
def test_sort():
'''
- Testing the sorting function
+ Test 17: Testing the sorting function
'''
#pylint: disable=C0103
circles = [Circle(4), Circle(1), Circle(3), Circle(2), Circle(5)]
circles.sort()
assert circles == [Circle(1), Circle(2), Circle(3), Circle(4), Circle(5)]
+
+
+def test_reflected_numerics():
+ '''
+ Test 18: Testing relected numerics
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(3)
+
+ assert c1 * 3 == 3 * c1
+
+
+def test_dividing_reflected_numerics():
+ '''
+ Test 19: Testing dividing relected numerics
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(3)
+
+ assert c1 / 3 == 3 / c1
From 5ce966c5596c79fdb2b304251e2ef5a3d34d9d39 Mon Sep 17 00:00:00 2001
From: Jeff Shabani
Date: Thu, 7 Mar 2019 08:30:46 -0800
Subject: [PATCH 086/354] Circle update
---
students/jeff_shabani/session08/Circle.py | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/students/jeff_shabani/session08/Circle.py b/students/jeff_shabani/session08/Circle.py
index 98dfa0d6..32f868d6 100644
--- a/students/jeff_shabani/session08/Circle.py
+++ b/students/jeff_shabani/session08/Circle.py
@@ -48,7 +48,7 @@ def __ipow__(self, other):
def __mul__(self, other):
return self.radius * other
- #allow for reversal of arguments
+ # allow for reversal of arguments
__rmul__ = __mul__
def __lt__(self, other):
@@ -71,6 +71,9 @@ def __str__(self):
class Sphere(Circle):
+ """
+ Sublclass of Circle
+ """
def volume(self):
return (4 / 3) * math.pi * (self.radius ** 3)
@@ -79,13 +82,9 @@ def area(self):
return 4 * math.pi * (self.radius ** 2)
def __repr__(self):
- return f'Sphere with radius of {self.radius} volume of {self.volume()} & surface area of {self.area()}'
+ return f'Sphere with radius of {self.radius} volume of ' \
+ f'{self.volume()} & surface area of {self.area()}'
def __str__(self):
- return f'Sphere with radius of {self.radius} volume of {self.volume()} & surface area of {self.area()}'
-
-
-if __name__ == '__main__':
- c1 = Circle(1)
- # c1.radius = -1
- print(c1)
+ return f'Sphere with radius of {self.radius} volume of ' \
+ f'{self.volume()} & surface area of {self.area()}'
From 4b7d32b94cbc0d13a2ce94e4607947a56695972d Mon Sep 17 00:00:00 2001
From: Jeff Shabani
Date: Thu, 7 Mar 2019 08:42:29 -0800
Subject: [PATCH 087/354] Circle update
---
.../jeff_shabani/session08/{Circle.py => circle.py} | 12 ++++++++++++
students/jeff_shabani/session08/test_circle.py | 12 ++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
rename students/jeff_shabani/session08/{Circle.py => circle.py} (84%)
diff --git a/students/jeff_shabani/session08/Circle.py b/students/jeff_shabani/session08/circle.py
similarity index 84%
rename from students/jeff_shabani/session08/Circle.py
rename to students/jeff_shabani/session08/circle.py
index 32f868d6..47a0b08c 100644
--- a/students/jeff_shabani/session08/Circle.py
+++ b/students/jeff_shabani/session08/circle.py
@@ -27,39 +27,49 @@ def diameter(self):
def diameter(self, value):
self.radius = value / 2
+ # make area non-settable
@property
def area(self):
return math.pi * pow(self.radius, 2)
+ # method to create a circle with the diameter
@classmethod
def from_diameter(cls, value):
radius = value / 2
return cls(radius)
+ # simple add method
def __add__(self, other):
return self.radius + other.radius
+ # augmented assignment add method
def __iadd__(self, other):
return self.radius + other.radius
+ # augmented assigment exponential method
def __ipow__(self, other):
return self.radius ** other
+ # multiplication method
def __mul__(self, other):
return self.radius * other
# allow for reversal of arguments
__rmul__ = __mul__
+ # less than comparison
def __lt__(self, other):
return self.radius < other.radius
+ # greater than comparison
def __gt__(self, other):
return self.radius > other.radius
+ # equality method
def __eq__(self, other):
return self.radius == other.radius
+ # non-equality method
def __ne__(self, other):
return self.radius != other.radius
@@ -75,9 +85,11 @@ class Sphere(Circle):
Sublclass of Circle
"""
+ # override Circle volume method
def volume(self):
return (4 / 3) * math.pi * (self.radius ** 3)
+ # override Circle area method
def area(self):
return 4 * math.pi * (self.radius ** 2)
diff --git a/students/jeff_shabani/session08/test_circle.py b/students/jeff_shabani/session08/test_circle.py
index 7925fde2..f10fa0d7 100644
--- a/students/jeff_shabani/session08/test_circle.py
+++ b/students/jeff_shabani/session08/test_circle.py
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
import unittest
-from Circle import *
+from circle import *
-class circleTests(unittest.TestCase):
+class CircleTests(unittest.TestCase):
def test_init(self):
"""test for instantiation"""
@@ -72,7 +72,7 @@ def test_extended_assignment(self):
self.assertEqual(c3, 144)
del c1, c2, c3
- #test for negative radius
+ # test for negative radius
@unittest.expectedFailure
def test_negative_radius(self):
c1 = Circle(-1)
@@ -89,10 +89,10 @@ def test_sphere_get_from_diameter(self):
self.assertEqual(s.volume(), 33.510321638291124)
del s
- def test_spehere_printing(self):
+ def test_sphere_printing(self):
s = Sphere(10)
- self.assertEqual(repr(s),'Sphere with radius of 10 volume of 4188.790204786391 & surface area of 1256.6370614359173')
-
+ self.assertEqual(repr(s),
+ 'Sphere with radius of 10 volume of 4188.790204786391 & surface area of 1256.6370614359173')
if __name__ == '__main__':
From 583277e39a9b208d0454a6c7151a727de3acd982 Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 09:07:42 -0800
Subject: [PATCH 088/354] Almost done I think
---
students/jesse_miller/session08/circle.py | 34 +++++++++++++++++++
.../jesse_miller/session08/test_circle.py | 15 ++++++++
2 files changed, 49 insertions(+)
diff --git a/students/jesse_miller/session08/circle.py b/students/jesse_miller/session08/circle.py
index e8657e00..86f40bcf 100644
--- a/students/jesse_miller/session08/circle.py
+++ b/students/jesse_miller/session08/circle.py
@@ -45,18 +45,23 @@ def from_diameter(cls, value):
'''
return cls(value/2)
+
def __str__(self):
return f'{self.__class__.__name__} with radius: {self.radius}'
+
def __repr__(self):
return f'{self.__class__.__name__}({self.radius})'
+
def __add__(self, other):
return self.radius + other.radius
+
def __rmul__(self, value):
return self.radius * value
+
def __mul__(self, value):
try:
return self.radius * value
@@ -68,9 +73,11 @@ def __mul__(self, value):
'''
rmul(self, value)
+
def __rtruediv__(self, value):
return self.radius / value
+
def __truediv__(self, value):
try:
return self.radius / value
@@ -82,27 +89,54 @@ def __truediv__(self, value):
'''
rdiv(self, value)
+
def __lt__(self, other):
if self.radius < other.radius:
return True
return False
+
def __gt__(self, other):
if self.radius < other.radius:
return True
return False
+
def __eq__(self, other):
if self.radius == other.radius:
return True
return False
+
def sort_var(self):
'''
This one wants a doc string for sorting, so this method sorts
'''
return self.radius
+
@staticmethod
def __sort__(circle_list):
return circle_list.sort(key=Circle.sort_var)
+
+class Sphere(Circle):
+ '''
+ Here goes spheres, we'll see how that works
+ '''
+ @property
+ def sphere_area(self):
+ '''
+ Calculating the area of the sphere
+ '''
+ try:
+ return 4 * pi * self.radius ** 2
+ except NotImplementedError:
+ print("This is not implemented")
+
+ @property
+ def sphere_volume(self):
+ '''
+ Determining the volume of said sphere, geometry isn't my strong suit
+ so I'm basically assuming that the math is right here.
+ '''
+ return 4 / 3 * pi * self.radius ** 3
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index 19dd48a5..df004f85 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -197,3 +197,18 @@ def test_dividing_reflected_numerics():
c1 = Circle(3)
assert c1 / 3 == 3 / c1
+
+
+def test_augmented_assignments():
+ '''
+ Test 20: Let's test augmented assignment I guess
+ '''
+ #pylint: disable=C0103
+ c1 = Circle(3)
+ c2 = Circle(3)
+
+ c1 += c2
+ assert c1 == 6
+
+ c1 *= 2
+ assert c1 == 12
From f0a8a3a6232381dd0215b17919685f82c48fa051 Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 09:13:13 -0800
Subject: [PATCH 089/354] It helps if you import the functions
---
students/jesse_miller/session08/circle.py | 10 ++++++++--
students/jesse_miller/session08/test_circle.py | 12 +++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/students/jesse_miller/session08/circle.py b/students/jesse_miller/session08/circle.py
index 86f40bcf..bc6f0aa8 100644
--- a/students/jesse_miller/session08/circle.py
+++ b/students/jesse_miller/session08/circle.py
@@ -119,12 +119,17 @@ def sort_var(self):
def __sort__(circle_list):
return circle_list.sort(key=Circle.sort_var)
+
+'''
+-------------------------------------------------------------------------------
+'''
+
class Sphere(Circle):
'''
Here goes spheres, we'll see how that works
'''
@property
- def sphere_area(self):
+ def area(self):
'''
Calculating the area of the sphere
'''
@@ -133,8 +138,9 @@ def sphere_area(self):
except NotImplementedError:
print("This is not implemented")
+
@property
- def sphere_volume(self):
+ def volume(self):
'''
Determining the volume of said sphere, geometry isn't my strong suit
so I'm basically assuming that the math is right here.
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index df004f85..681e8017 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -7,7 +7,7 @@
'''
from math import pi
import pytest
-from circle import Circle
+from circle import Circle, Sphere
def test_empty_circle():
@@ -212,3 +212,13 @@ def test_augmented_assignments():
c1 *= 2
assert c1 == 12
+
+'''
+Spheres!
+'''
+
+def test_new_sphere():
+ '''
+ Here goes this test
+ '''
+ Sphere(4)
From 4f012dca10d5255950e5e745bf0c8a48d5d11d29 Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 09:19:45 -0800
Subject: [PATCH 090/354] So far so good
---
.../jesse_miller/session08/test_circle.py | 40 ++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index 681e8017..2f705877 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -219,6 +219,44 @@ def test_augmented_assignments():
def test_new_sphere():
'''
- Here goes this test
+ Test 21: Here goes this test
'''
Sphere(4)
+
+def test_empty_sphere():
+ '''
+ Test 22: No values insertered.
+ '''
+ #pylint: disable=E1120
+ with pytest.raises(TypeError):
+ Sphere()
+
+
+def test_str_sphere():
+ '''
+ Test 23: Testing string insertion.
+ '''
+ #pylint: disable=E1120, C0103
+ s = Sphere(13)
+ assert str(s) == "Sphere with radius: 13"
+
+
+def test_repr_sphere():
+ '''
+ Test 24: Testing repr fuctionality.
+ '''
+ #pylint: disable=E1120, C0103
+ s = Sphere(12)
+ assert repr(s) == "Sphere(12)"
+
+
+def test_sphere_volume():
+ pass
+
+
+def test_sphere_area():
+ pass
+
+
+def test_sphere_set_diameter():
+ pass
From 97cb8630538950bad70690e179cf4541a2817d54 Mon Sep 17 00:00:00 2001
From: Douglas Klos
Date: Thu, 7 Mar 2019 09:11:54 -0800
Subject: [PATCH 091/354] Timer() contextmanager seems to work
---
students/douglas_klos/.gitignore | 1 -
.../extra/context/raising_an_assert.py | 13 -----
.../extra/context/run_timer_context.py | 58 +++++++++++++++++++
.../extra/context/timer_context.py | 25 ++++++++
.../extra/lambda/lambda_keyword.py | 2 +-
.../douglas_klos/extra/lambda/test_lambda.py | 4 +-
.../douglas_klos/extra/numerals/numerals.py | 2 +-
.../extra/numerals/test_numerals.py | 4 +-
students/douglas_klos/extra/rot13/rot13.py | 4 +-
.../douglas_klos/extra/rot13/test_rot13.py | 2 +-
10 files changed, 92 insertions(+), 23 deletions(-)
delete mode 100644 students/douglas_klos/extra/context/raising_an_assert.py
create mode 100755 students/douglas_klos/extra/context/run_timer_context.py
create mode 100755 students/douglas_klos/extra/context/timer_context.py
diff --git a/students/douglas_klos/.gitignore b/students/douglas_klos/.gitignore
index 62537ae9..5e5a6e9c 100644
--- a/students/douglas_klos/.gitignore
+++ b/students/douglas_klos/.gitignore
@@ -1,7 +1,6 @@
*.swp
*.back
.vscode
-../.vscode/
session7/execution_times.txt
session7/html_render.zip
session7/test_html_output1.html
diff --git a/students/douglas_klos/extra/context/raising_an_assert.py b/students/douglas_klos/extra/context/raising_an_assert.py
deleted file mode 100644
index 0ea86ea5..00000000
--- a/students/douglas_klos/extra/context/raising_an_assert.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env python
-
-"""
-examples of forcing and an AssertionError
-"""
-
-
-def test_raise_assertion():
- raise AssertionError("this was done with a direct raise")
-
-
-def test_trasditional_assert():
- assert False, "this was done with a forced assert"
diff --git a/students/douglas_klos/extra/context/run_timer_context.py b/students/douglas_klos/extra/context/run_timer_context.py
new file mode 100755
index 00000000..c7ed28e1
--- /dev/null
+++ b/students/douglas_klos/extra/context/run_timer_context.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+#pylint: disable=C0103
+
+# Douglas Klos
+# March 7th, 2019
+# Python 210, Extra
+# run_timer_context.py
+
+""" Run file for context manager testing """
+
+import io
+import time
+from contextlib import contextmanager
+import timer_context as tc
+
+
+
+@contextmanager
+def local_timer(out_file, name=''):
+ """ Context manager that returns execution time """
+ local_time = time.time()
+ try:
+ yield local_time
+ finally:
+ local_time = time.time() - local_time
+ out_file.write(f'{name} execution took {local_time} seconds')
+
+
+def timer_test():
+ """ Runs a loop with context manager and prints execution time """
+ outfile = io.StringIO()
+
+ with tc.Timer(outfile, 'timer_test'):
+ for i in range(1000000):
+ i = i ** 20
+
+ print(outfile.getvalue())
+
+
+def timer_test2():
+ """ Runs a loop with context manager and prints execution time """
+ outfile = io.StringIO()
+
+ with local_timer(outfile, 'timer_test2'):
+ for i in range(1000000):
+ i = i ** 20
+
+ print(outfile.getvalue())
+
+
+def main():
+ """ Main, calls different tests """
+ timer_test()
+ timer_test2()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/students/douglas_klos/extra/context/timer_context.py b/students/douglas_klos/extra/context/timer_context.py
new file mode 100755
index 00000000..b0200032
--- /dev/null
+++ b/students/douglas_klos/extra/context/timer_context.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+# Douglas Klos
+# March 7th, 2019
+# Python 210, Extra
+# timer_context.py
+
+""" A simple class based context manager to calculate execution time """
+
+import time
+
+
+class Timer():
+ """ A simple class based context manager to calculate execution time """
+ def __init__(self, file_name, name=''):
+ self.file_obj = file_name
+ self.name = name
+ self.start = time.time
+
+ def __enter__(self):
+ self.start = time.time()
+
+ def __exit__(self, exeception_type, exeception_value, traceback):
+ self.file_obj.write(f'{self.name} execution took {time.time() - self.start} seconds')
+ return self.file_obj
diff --git a/students/douglas_klos/extra/lambda/lambda_keyword.py b/students/douglas_klos/extra/lambda/lambda_keyword.py
index 1b20ee6b..80f64455 100755
--- a/students/douglas_klos/extra/lambda/lambda_keyword.py
+++ b/students/douglas_klos/extra/lambda/lambda_keyword.py
@@ -2,7 +2,7 @@
# Douglas Klos
# March 6th, 2019
-# Python 210, Session 8
+# Python 210, Extra
# lambda_keyword.py
diff --git a/students/douglas_klos/extra/lambda/test_lambda.py b/students/douglas_klos/extra/lambda/test_lambda.py
index 0d4789e1..00d70f47 100755
--- a/students/douglas_klos/extra/lambda/test_lambda.py
+++ b/students/douglas_klos/extra/lambda/test_lambda.py
@@ -2,8 +2,8 @@
# Douglas Klos
# March 6th, 2019
-# Python 210, Session 8
-# lambda_keyword.py
+# Python 210, Extra
+# test_lambda.py
"""
Some simple tests for the "lambda and keyword magic"
diff --git a/students/douglas_klos/extra/numerals/numerals.py b/students/douglas_klos/extra/numerals/numerals.py
index 49b23912..344a340f 100755
--- a/students/douglas_klos/extra/numerals/numerals.py
+++ b/students/douglas_klos/extra/numerals/numerals.py
@@ -5,7 +5,7 @@
# Douglas Klos
# March 6th, 2019
-# Python 210, Session 8
+# Python 210, Extra
# numerals.py
diff --git a/students/douglas_klos/extra/numerals/test_numerals.py b/students/douglas_klos/extra/numerals/test_numerals.py
index dbdb6941..bc20abb0 100755
--- a/students/douglas_klos/extra/numerals/test_numerals.py
+++ b/students/douglas_klos/extra/numerals/test_numerals.py
@@ -5,8 +5,8 @@
# Douglas Klos
# March 6th, 2019
-# Python 210, Session 8
-# numerals.py
+# Python 210, Extra
+# test_numerals.py
import pytest
diff --git a/students/douglas_klos/extra/rot13/rot13.py b/students/douglas_klos/extra/rot13/rot13.py
index 9cb11bb1..46e9f14b 100755
--- a/students/douglas_klos/extra/rot13/rot13.py
+++ b/students/douglas_klos/extra/rot13/rot13.py
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
-""" Class to convert rot13 'encrypt' """
+""" Function to convert rot13 'encrypt' """
# Douglas Klos
# March 6th, 2019
-# Python 210, Session 8
+# Python 210, Extra
# rot13.py
# a - z == 97 - 122
diff --git a/students/douglas_klos/extra/rot13/test_rot13.py b/students/douglas_klos/extra/rot13/test_rot13.py
index d0e9fbde..563b5821 100755
--- a/students/douglas_klos/extra/rot13/test_rot13.py
+++ b/students/douglas_klos/extra/rot13/test_rot13.py
@@ -4,7 +4,7 @@
# Douglas Klos
# March 6th, 2019
-# Python 210, Session 8
+# Python 210, Extra
# test_rot13.py
import rot13
From 5d0e6c9c3ee5fb7ccd99a7bc74abf3e4e50884f5 Mon Sep 17 00:00:00 2001
From: Jeff Shabani
Date: Thu, 7 Mar 2019 09:32:15 -0800
Subject: [PATCH 092/354] Circle update
---
students/jeff_shabani/session08/circle.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/students/jeff_shabani/session08/circle.py b/students/jeff_shabani/session08/circle.py
index 47a0b08c..f4a1ebd4 100644
--- a/students/jeff_shabani/session08/circle.py
+++ b/students/jeff_shabani/session08/circle.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
+import coverage
import math
"""
From 9a1a79d1129c80ececc70a83dfcfb67a222753e3 Mon Sep 17 00:00:00 2001
From: UncleanlyCleric
Date: Thu, 7 Mar 2019 09:51:43 -0800
Subject: [PATCH 093/354] Volume test is go
---
students/jesse_miller/session08/test_circle.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index 2f705877..c8ef9a52 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -251,12 +251,22 @@ def test_repr_sphere():
def test_sphere_volume():
- pass
+ '''
+ Test 24: Testing sphere volume fuctionality.
+ '''
+ s = Sphere(4)
+ assert s.volume == 4 / 3 * pi * 4 ** 3
def test_sphere_area():
+ '''
+ Test 24: Testing sphere area fuctionality.
+ '''
pass
def test_sphere_set_diameter():
+ '''
+ Test 24: Testing set diameter fuctionality.
+ '''
pass
From 2c49640b0b5d377f681a8b2d341bb23504646a2e Mon Sep 17 00:00:00 2001
From: Douglas Klos
Date: Thu, 7 Mar 2019 10:14:02 -0800
Subject: [PATCH 094/354] Raises() contextmanager class
---
.../extra/context/raises/raises_context.py | 26 ++++++++++++
.../context/raises/test_raises_context.py | 42 +++++++++++++++++++
.../context/{ => timer}/run_timer_context.py | 1 -
.../context/{ => timer}/timer_context.py | 0
4 files changed, 68 insertions(+), 1 deletion(-)
create mode 100755 students/douglas_klos/extra/context/raises/raises_context.py
create mode 100755 students/douglas_klos/extra/context/raises/test_raises_context.py
rename students/douglas_klos/extra/context/{ => timer}/run_timer_context.py (99%)
rename students/douglas_klos/extra/context/{ => timer}/timer_context.py (100%)
diff --git a/students/douglas_klos/extra/context/raises/raises_context.py b/students/douglas_klos/extra/context/raises/raises_context.py
new file mode 100755
index 00000000..9137bb1b
--- /dev/null
+++ b/students/douglas_klos/extra/context/raises/raises_context.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+# Douglas Klos
+# March 7th, 2019
+# Python 210, Extra
+# raises_context.py
+
+""" A simple class based context manager to calculate execution time """
+
+# This seems entirely too simple... Yet it seems to work...
+# Am I missing something?
+
+
+class Raises():
+ """ A simple class based context manager to calculate execution time """
+ def __init__(self, value):
+ self.value = value
+
+ def __enter__(self):
+ pass
+
+ def __exit__(self, exception_type, exeception_value, traceback):
+ if exception_type == self.value:
+ return True
+ return False
+
\ No newline at end of file
diff --git a/students/douglas_klos/extra/context/raises/test_raises_context.py b/students/douglas_klos/extra/context/raises/test_raises_context.py
new file mode 100755
index 00000000..40630d07
--- /dev/null
+++ b/students/douglas_klos/extra/context/raises/test_raises_context.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+#pylint: disable=C0103,W0104, W0107
+
+# Douglas Klos
+# March 7th, 2019
+# Python 210, Extra
+# test_raises_context.py
+
+""" Run file for context manager testing """
+
+import raises_context as rc
+
+
+def test1():
+ """ Tests AssertionError """
+ with rc.Raises(AssertionError):
+ raise AssertionError
+
+
+def test2():
+ """ Tests ZeroDivisionError """
+ with rc.Raises(ZeroDivisionError):
+ 1 / 0
+
+
+def test3():
+ """ Tests that Raises fails properly """
+ # We expcet the next line to fail, and it does
+ # with rc.Raises(AssertionError):
+ # raise ZeroDivisionError
+ pass
+
+
+def main():
+ """ Main, calls different tests """
+ test1()
+ test2()
+ test3()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/students/douglas_klos/extra/context/run_timer_context.py b/students/douglas_klos/extra/context/timer/run_timer_context.py
similarity index 99%
rename from students/douglas_klos/extra/context/run_timer_context.py
rename to students/douglas_klos/extra/context/timer/run_timer_context.py
index c7ed28e1..81098db3 100755
--- a/students/douglas_klos/extra/context/run_timer_context.py
+++ b/students/douglas_klos/extra/context/timer/run_timer_context.py
@@ -14,7 +14,6 @@
import timer_context as tc
-
@contextmanager
def local_timer(out_file, name=''):
""" Context manager that returns execution time """
diff --git a/students/douglas_klos/extra/context/timer_context.py b/students/douglas_klos/extra/context/timer/timer_context.py
similarity index 100%
rename from students/douglas_klos/extra/context/timer_context.py
rename to students/douglas_klos/extra/context/timer/timer_context.py
From 0576a3f07ce448a86c77827ad5ca30c88550e7f0 Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 10:15:19 -0800
Subject: [PATCH 095/354] Finished with test_circle.py and circle.py
---
students/jesse_miller/session08/test_circle.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/students/jesse_miller/session08/test_circle.py b/students/jesse_miller/session08/test_circle.py
index c8ef9a52..70f01cc5 100644
--- a/students/jesse_miller/session08/test_circle.py
+++ b/students/jesse_miller/session08/test_circle.py
@@ -254,6 +254,7 @@ def test_sphere_volume():
'''
Test 24: Testing sphere volume fuctionality.
'''
+ #pylint: disable=E1120, C0103
s = Sphere(4)
assert s.volume == 4 / 3 * pi * 4 ** 3
@@ -262,11 +263,17 @@ def test_sphere_area():
'''
Test 24: Testing sphere area fuctionality.
'''
- pass
+ #pylint: disable=E1120, C0103
+ s = Sphere(6)
+ assert s.area == 4 * pi * 6 ** 2
def test_sphere_set_diameter():
'''
Test 24: Testing set diameter fuctionality.
'''
- pass
+ #pylint: disable=E1120, C0103
+ s = Sphere.from_diameter(8)
+
+ assert s.area == 4 * pi * 4 ** 2
+ assert s.volume == 4 / 3 * pi * 4 ** 3
From 2206f427800829278b8cf6639e231150f2bd86bb Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 10:38:55 -0800
Subject: [PATCH 096/354] Initial commit. I... I'm going to have to framework
this first if I want it installable.
---
students/jesse_miller/session09/mailroom.py | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 students/jesse_miller/session09/mailroom.py
diff --git a/students/jesse_miller/session09/mailroom.py b/students/jesse_miller/session09/mailroom.py
new file mode 100644
index 00000000..4a9b90a1
--- /dev/null
+++ b/students/jesse_miller/session09/mailroom.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+'''
+Well, here it goes. An object oriented verion of my mailroom program. This,
+is going to be complicated for me because I'm already used to how the old one
+works. (Of course, having said old one, I am now dubbing this implementation
+Cthulu in my head.)
+'''
From b2c3d6f2041eec02c48d836a84801a88d0b1b0cf Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 10:57:20 -0800
Subject: [PATCH 097/354] Okay, here's the structure I think I'll need. Don't
be surprised if this changes though. It's supposed to be installable, so...
---
students/jesse_miller/session09/donor_info.py | 1 +
students/jesse_miller/session09/mail_function.py | 1 +
students/jesse_miller/session09/mail_menu.py | 1 +
students/jesse_miller/session09/test_mailroom.py | 1 +
4 files changed, 4 insertions(+)
create mode 100644 students/jesse_miller/session09/donor_info.py
create mode 100644 students/jesse_miller/session09/mail_function.py
create mode 100644 students/jesse_miller/session09/mail_menu.py
create mode 100644 students/jesse_miller/session09/test_mailroom.py
diff --git a/students/jesse_miller/session09/donor_info.py b/students/jesse_miller/session09/donor_info.py
new file mode 100644
index 00000000..e5a0d9b4
--- /dev/null
+++ b/students/jesse_miller/session09/donor_info.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
diff --git a/students/jesse_miller/session09/mail_function.py b/students/jesse_miller/session09/mail_function.py
new file mode 100644
index 00000000..e5a0d9b4
--- /dev/null
+++ b/students/jesse_miller/session09/mail_function.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
diff --git a/students/jesse_miller/session09/mail_menu.py b/students/jesse_miller/session09/mail_menu.py
new file mode 100644
index 00000000..e5a0d9b4
--- /dev/null
+++ b/students/jesse_miller/session09/mail_menu.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
diff --git a/students/jesse_miller/session09/test_mailroom.py b/students/jesse_miller/session09/test_mailroom.py
new file mode 100644
index 00000000..e5a0d9b4
--- /dev/null
+++ b/students/jesse_miller/session09/test_mailroom.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
From 74921636ad2be72439444ecf9c399d48128dcd0a Mon Sep 17 00:00:00 2001
From: Mahmood08
Date: Thu, 7 Mar 2019 11:32:51 -0800
Subject: [PATCH 098/354] finished step 7
---
students/shirin_ak/Session08/Circle.py | 46 ++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 students/shirin_ak/Session08/Circle.py
diff --git a/students/shirin_ak/Session08/Circle.py b/students/shirin_ak/Session08/Circle.py
new file mode 100644
index 00000000..8fa6a7bd
--- /dev/null
+++ b/students/shirin_ak/Session08/Circle.py
@@ -0,0 +1,46 @@
+
+import math
+class Circle():
+ def __init__(self, radius):
+ # STEP 1 The radius is a required parameter
+ self.radius = radius
+ # STEP 2 Add a 'diameter' property
+ @property
+ def diameter(self):
+ return self.radius*2
+
+ #STEP 3 set up the diameter property
+ @diameter.setter
+ def diameter(self, value):
+ self.diameter = value
+ self.radius = value/2
+
+ #STEP 4 Add an area property
+ @property
+ def area(self):
+ return math.pi * (self.radius ** 2)
+
+ # STEP 5 Add an “alternate constructor” that
+ #lets the user create a Circle directly with the diameter:
+ @classmethod
+ def from_diameter(class_object, diameter):
+ radius = diameter/2
+ return class_object(radius)
+
+ #STEP 6 Add __str__ and __repr__ methods to your Circle class.
+
+ def __str__(self):
+ return "Circle with radius: {:.6f}".format(self.radius)
+
+ def __repr__(self):
+ return "Circle({r})".format(r=self.radius)
+ #STEP 7 Add two circles and multiply one by a number
+ def ___add__(self, other):
+ c1 = self.radius
+ c2 = other.radius
+ return Circle(c1+c2)
+# def __mul__(self, other):
+
+
+
+
From 451f4d6978016ec04392b5f1a7f8df5937c60d0b Mon Sep 17 00:00:00 2001
From: Mahmood08
Date: Thu, 7 Mar 2019 11:46:18 -0800
Subject: [PATCH 099/354] added files
---
students/shirin_ak/Session08/test_Circle.py | 29 +++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 students/shirin_ak/Session08/test_Circle.py
diff --git a/students/shirin_ak/Session08/test_Circle.py b/students/shirin_ak/Session08/test_Circle.py
new file mode 100644
index 00000000..655c8287
--- /dev/null
+++ b/students/shirin_ak/Session08/test_Circle.py
@@ -0,0 +1,29 @@
+import pytest
+
+from Circle import Circle
+
+
+def test_radius():
+ c = Circle(4)
+ assert c.radius == 4
+
+def test_diameter():
+ c = Circle(4)
+ assert c.diameter == 8
+
+
+def test_set_diameter():
+ c = Circle(4)
+ c.diameter = 10
+ assert c.diameter == 10
+ assert c.radius == 5
+
+def test_area():
+ c = Circle(1)
+
+ assert c.area == 3.141592653589793
+
+def test_constructor():
+ c = Circle.from_diameter(4)
+ assert c.diameter == 4
+ assert c.radius == 2
From c940164de3985099a5783d382a0877dfc6b0040d Mon Sep 17 00:00:00 2001
From: J Miller
Date: Thu, 7 Mar 2019 11:54:20 -0800
Subject: [PATCH 100/354] Renaming
---
students/jesse_miller/session09/mail_menu.py | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 students/jesse_miller/session09/mail_menu.py
diff --git a/students/jesse_miller/session09/mail_menu.py b/students/jesse_miller/session09/mail_menu.py
deleted file mode 100644
index e5a0d9b4..00000000
--- a/students/jesse_miller/session09/mail_menu.py
+++ /dev/null
@@ -1 +0,0 @@
-#!/usr/bin/env python3
From f5a68393bfdd369f5b8fffe19ca5bae4f0afc7e8 Mon Sep 17 00:00:00 2001
From: J Miller
Date: Thu, 7 Mar 2019 11:54:31 -0800
Subject: [PATCH 101/354] Renaming
---
students/jesse_miller/session09/mail_function.py | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 students/jesse_miller/session09/mail_function.py
diff --git a/students/jesse_miller/session09/mail_function.py b/students/jesse_miller/session09/mail_function.py
deleted file mode 100644
index e5a0d9b4..00000000
--- a/students/jesse_miller/session09/mail_function.py
+++ /dev/null
@@ -1 +0,0 @@
-#!/usr/bin/env python3
From 17c27840e40b413de7e94d407b908a0f79a3ee92 Mon Sep 17 00:00:00 2001
From: J Miller
Date: Thu, 7 Mar 2019 11:54:45 -0800
Subject: [PATCH 102/354] Renaming
Simplicity is key
---
students/jesse_miller/session09/donor_info.py | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 students/jesse_miller/session09/donor_info.py
diff --git a/students/jesse_miller/session09/donor_info.py b/students/jesse_miller/session09/donor_info.py
deleted file mode 100644
index e5a0d9b4..00000000
--- a/students/jesse_miller/session09/donor_info.py
+++ /dev/null
@@ -1 +0,0 @@
-#!/usr/bin/env python3
From 95094a9479946a6881a41fca6641f5b44f30acd4 Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 11:55:09 -0800
Subject: [PATCH 103/354] Renamed files for simplicity
---
students/jesse_miller/session09/donors.py | 1 +
students/jesse_miller/session09/mailings.py | 1 +
students/jesse_miller/session09/menus.py | 1 +
3 files changed, 3 insertions(+)
create mode 100644 students/jesse_miller/session09/donors.py
create mode 100644 students/jesse_miller/session09/mailings.py
create mode 100644 students/jesse_miller/session09/menus.py
diff --git a/students/jesse_miller/session09/donors.py b/students/jesse_miller/session09/donors.py
new file mode 100644
index 00000000..e5a0d9b4
--- /dev/null
+++ b/students/jesse_miller/session09/donors.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
diff --git a/students/jesse_miller/session09/mailings.py b/students/jesse_miller/session09/mailings.py
new file mode 100644
index 00000000..e5a0d9b4
--- /dev/null
+++ b/students/jesse_miller/session09/mailings.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
diff --git a/students/jesse_miller/session09/menus.py b/students/jesse_miller/session09/menus.py
new file mode 100644
index 00000000..e5a0d9b4
--- /dev/null
+++ b/students/jesse_miller/session09/menus.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
From 623a3d421438397bcaa912cf1d8bc1acaef5007d Mon Sep 17 00:00:00 2001
From: Jeremy
Date: Thu, 7 Mar 2019 11:58:07 -0800
Subject: [PATCH 104/354] Committing before starting on Lesson 08 Circle Class
assignment.
---
.../lesson07_exercise/html_renderer.zip | Bin 0 -> 5265 bytes
.../lesson08_exercise/circle_class.py | 0
.../lesson08_exercise/properties_example.py | 33 ++++++++++++++++++
3 files changed, 33 insertions(+)
create mode 100644 students/jeremy_m/lesson07_exercise/html_renderer.zip
create mode 100644 students/jeremy_m/lesson08_exercise/circle_class.py
create mode 100644 students/jeremy_m/lesson08_exercise/properties_example.py
diff --git a/students/jeremy_m/lesson07_exercise/html_renderer.zip b/students/jeremy_m/lesson07_exercise/html_renderer.zip
new file mode 100644
index 0000000000000000000000000000000000000000..4405593a26e8de90db3340f6a46b91db49c5c842
GIT binary patch
literal 5265
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
Date: Thu, 7 Mar 2019 12:55:23 -0800
Subject: [PATCH 105/354] Obviously, I just copied the functions from the old
program into the new programs. This is not the solution to the problem, this
is reference material
---
students/jesse_miller/session09/donors.py | 68 +++++++++++++++++++++
students/jesse_miller/session09/mailings.py | 57 +++++++++++++++++
students/jesse_miller/session09/menus.py | 40 ++++++++++++
3 files changed, 165 insertions(+)
diff --git a/students/jesse_miller/session09/donors.py b/students/jesse_miller/session09/donors.py
index e5a0d9b4..c3a68350 100644
--- a/students/jesse_miller/session09/donors.py
+++ b/students/jesse_miller/session09/donors.py
@@ -1 +1,69 @@
#!/usr/bin/env python3
+
+donors = {'Robert Smith': [435.56, 125.23, 357.10],
+ 'JD Cronise': [123.12],
+ 'Chris Stapleton': [243.87, 111.32],
+ 'Dave Lombardo': [63.23, 422.87, 9432.01],
+ 'Randy Blythe': [223.50, 8120.32],
+ 'Devin Townsand': [431.12, 342.92, 5412.45],
+ }
+
+
+def donor_list():
+ '''
+ This when done properly, will print the list of donor names
+ '''
+ print(f"\n{'-'*15}\nList of Donors:\n{'-'*15}")
+ for donor in donors:
+ print(donor)
+ print(f"{'-'*15}\n")
+
+
+def donor_report():
+ '''
+ This will be the donation report section
+ '''
+ summary = []
+ headers = ['Donor Name', 'Total Given', 'Times Donated', 'Average Gift']
+
+ print(f"\n{'-'*80}\n{{:17}} | {{:<19}} | {{:<15}} | {{:<19}}\n{'-'*80}"\
+ .format(headers[0], headers[1], headers[2], headers[3]))
+
+ for k, v in donors.items():
+ summary.append([k, (sum(v)), (len(v)), (sum(v) / len(v))])
+ summary.sort(key=lambda d: d[1], reverse=True)
+
+ for x_value in summary:
+ print('{:17} | ${:<18,.2f} | {:<15} | ${:<16,.2f}'.format
+ (x_value[0], x_value[1], x_value[2], x_value[3]))
+ print(f"{'-'*80}\n")
+
+
+def donor_add(current_donor):
+ '''
+ This allows addition of new donors
+ '''
+ donors[current_donor] = []
+ while True:
+ try:
+ d_num = int(input('How many donations were made: '))
+ while d_num > 0:
+ new_don = float(input('Enter their donation: '))
+ donors[current_donor].append(new_don)
+ d_num -= 1
+ mail_send(current_donor)
+ except (KeyboardInterrupt, EOFError, ValueError):
+ break
+
+
+def donor_del():
+ '''
+ This section allows the user to delete a donor
+ '''
+ try:
+ donor_list()
+ del_donor = str(input('Enter the name of the donor to remove: '))
+ del donors[del_donor]
+ donor_list()
+ except (KeyboardInterrupt, EOFError, ValueError):
+ safe_input()
diff --git a/students/jesse_miller/session09/mailings.py b/students/jesse_miller/session09/mailings.py
index e5a0d9b4..723f223f 100644
--- a/students/jesse_miller/session09/mailings.py
+++ b/students/jesse_miller/session09/mailings.py
@@ -1 +1,58 @@
#!/usr/bin/env python3
+
+import datetime
+
+MAIL = ('\nHello {}, \n'
+ '\n'
+ 'We are writing to thank you for you generous donation\n'
+ 'to our foundation. Your contributions for the year \n'
+ 'total ${:,.2f} in {} disbursements. \n'
+ '\n'
+ 'Again, the foundation thanks you for your support, \n'
+ 'and we hope to remain in contact with you in this new \n'
+ 'year.\n'
+ '\n'
+ 'Sincerely, \n'
+ 'Ecumenical Slobs LLC \n')
+
+
+def mail_send(current_donor):
+ '''
+ This function now contains both the singular and the all mails. I am
+ planning on rewriting it to print to terminal and mail for single or all.
+ '''
+ path = os.getcwd()
+
+ if current_donor in donors:
+ donor_math = donors[current_donor]
+ directory = path + '/donors/' + current_donor + '/'
+ filename = current_donor + ' - ' \
+ + datetime.datetime.now().strftime('%s') + '.txt'
+ mail_format(current_donor, donor_math, directory, filename)
+ print('\nFile created\n')
+
+ else:
+ for k in donors:
+ current_donor = k
+ donor_math = donors[current_donor]
+ directory = path + '/donors/' + current_donor + '/'
+ filename = current_donor + ' - ' \
+ + datetime.datetime.now().strftime('%s') + '.txt'
+ mail_format(current_donor, donor_math, directory, filename)
+ print('\nFiles created\n')
+
+
+def mail_format(current_donor, donor_math, directory, filename):
+ '''
+ This is the formating for the mail print and file. This allows us to
+ have both files and terminal output for single donors as well as multiple
+ '''
+ print('\n')
+ print(MAIL.format(current_donor, (sum(donor_math)), (len(donor_math))))
+
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+
+ with open(directory + filename, 'w+') as outfile:
+ outfile.write('{}\n'.format(MAIL.format(current_donor,\
+ (sum(donor_math)), (len(donor_math)))))
diff --git a/students/jesse_miller/session09/menus.py b/students/jesse_miller/session09/menus.py
index e5a0d9b4..29eb2b51 100644
--- a/students/jesse_miller/session09/menus.py
+++ b/students/jesse_miller/session09/menus.py
@@ -1 +1,41 @@
#!/usr/bin/env python3
+
+def goodbye():
+ '''
+ Gracefully exits
+ '''
+ print('Goodbye!')
+ sys.exit()
+
+
+MENU_CHOICE = {'report': donor_report,
+ 'send': donor_mail_choice,
+ 'list': donor_list,
+ 'delete': donor_del,
+ 'quit': goodbye
+ }
+
+
+def safe_input():
+ '''
+ This will be for handling keyboard exceptions
+ '''
+ return None
+
+
+def donor_mail_choice():
+ '''
+ This section allows the user to mail a donor
+ '''
+ current_donor = ''
+ donor_list()
+ try:
+ current_donor = str(input('Who would you like to mail (all for all): '))
+ if current_donor in donors:
+ mail_send(current_donor)
+ elif current_donor == 'all':
+ mail_send(current_donor)
+ else:
+ donor_add(current_donor)
+ except (KeyboardInterrupt, EOFError, ValueError):
+ safe_input()
From d2c99660b64971c869024190b51332becaa98bbd Mon Sep 17 00:00:00 2001
From: UncleanlyClericr
Date: Thu, 7 Mar 2019 15:56:54 -0800
Subject: [PATCH 106/354] Starting on framework
---
students/jesse_miller/session09/donors.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/students/jesse_miller/session09/donors.py b/students/jesse_miller/session09/donors.py
index c3a68350..e6d2205e 100644
--- a/students/jesse_miller/session09/donors.py
+++ b/students/jesse_miller/session09/donors.py
@@ -1,4 +1,13 @@
#!/usr/bin/env python3
+'''
+This is where we start. Building out the donor database and manipulation
+Everything else in this program will be dependent on this one.
+'''
+class Donor():
+
+ def __init__(self, name):
+ self.name = name
+ self.donation = {}
donors = {'Robert Smith': [435.56, 125.23, 357.10],
'JD Cronise': [123.12],
From cbed41e4f7ec3c1e4e4a38255baa8786efc1e8ac Mon Sep 17 00:00:00 2001
From: admin <23247076+Rockwell70@users.noreply.github.com>
Date: Thu, 7 Mar 2019 18:01:29 -0800
Subject: [PATCH 107/354] html_render update
---
students/jeff_shabani/session07/html_render.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/students/jeff_shabani/session07/html_render.py b/students/jeff_shabani/session07/html_render.py
index 17374899..7ca21f97 100644
--- a/students/jeff_shabani/session07/html_render.py
+++ b/students/jeff_shabani/session07/html_render.py
@@ -78,7 +78,7 @@ def render(self, file_name, cur_indent=''):
:param file_name:
:param cur_indent:
"""
- file_name.write(f'{self._front_tag()} ')
+ file_name.write(f'{self._front_tag()[:-1]} ')
for k, v in self.attrs.items():
file_name.write(f'{k}="{v}"')
file_name.write(f'{self._front_tag()}')
From 651432643270828d87e1e584c27528afbb04d245 Mon Sep 17 00:00:00 2001
From: admin <23247076+Rockwell70@users.noreply.github.com>
Date: Thu, 7 Mar 2019 18:01:40 -0800
Subject: [PATCH 108/354] html_render update
---
.../session07/test_html_render_unittest.py | 36 +++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 students/jeff_shabani/session07/test_html_render_unittest.py
diff --git a/students/jeff_shabani/session07/test_html_render_unittest.py b/students/jeff_shabani/session07/test_html_render_unittest.py
new file mode 100644
index 00000000..731bb6ee
--- /dev/null
+++ b/students/jeff_shabani/session07/test_html_render_unittest.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+import io
+import unittest
+
+from html_render import *
+
+def render_result(element, ind=""):
+ """
+ calls the element's render method, and returns what got rendered as a
+ string
+ """
+ # the StringIO object is a "file-like" object -- something that
+ # provides the methods of a file, but keeps everything in memory
+ # so it can be used to test code that writes to a file, without
+ # having to actually write to disk.
+ outfile = io.StringIO()
+ # this so the tests will work before we tackle indentation
+ if ind:
+ element.render(outfile, ind)
+ else:
+ element.render(outfile)
+ return outfile.getvalue()
+
+
+class HTMLRenderTests(unittest.TestCase):
+
+ def test_a(self):
+ ca = A("http://google.com/", "link to google")
+ file_contents = render_result(ca)
+ print(file_contents)
+
+ self.assertEqual(file_contents, f'link to google')
+
+
+if __name__ == '__main__':
+ unittest.main()
From 74c77f4bfa3994acdb588e74f730af6a9afb7083 Mon Sep 17 00:00:00 2001
From: Rockwell70
Date: Fri, 8 Mar 2019 08:54:42 -0800
Subject: [PATCH 109/354] html_render update
---
.../jeff_shabani/session07/html_render.py | 42 +++++-------
.../session07/test_html_render.py | 68 +++++++++----------
.../session07/test_html_render_unittest.py | 18 ++++-
3 files changed, 68 insertions(+), 60 deletions(-)
diff --git a/students/jeff_shabani/session07/html_render.py b/students/jeff_shabani/session07/html_render.py
index 7ca21f97..2a94ee57 100644
--- a/students/jeff_shabani/session07/html_render.py
+++ b/students/jeff_shabani/session07/html_render.py
@@ -81,7 +81,7 @@ def render(self, file_name, cur_indent=''):
file_name.write(f'{self._front_tag()[:-1]} ')
for k, v in self.attrs.items():
file_name.write(f'{k}="{v}"')
- file_name.write(f'{self._front_tag()}')
+ file_name.write(f'>')
file_name.write(f'{self.content[0]}')
file_name.write(f'{self._end_tag()}')
@@ -132,30 +132,22 @@ def __init__(self, link, content=None, **attrs):
attrs['href'] = link
super().__init__(content, **attrs)
- # def __init__(self, link, content):
- # self.link = link
- # self.content = content
- # #super(Element).__init__()
- #
- # def render(self, file_name):
- # filename.write()
- # head = 'a href='
- # tail = 'a'
- # outtext = f'<{head}"{self.link}">{self.content}{tail}>'
- # with open(f'{file_name}.html', 'w') as file:
- # file.write(outtext)
-#
-# class Ul(Element):
-# """
-# Step 7: Ul class
-# """
-# ul = []
-#
-# class Li(Element):
-# """
-# Step 7: Li class
-# """
-# list_element = ''
+
+class Ul(Element):
+ """
+ Step 7: Ul class
+ """
+ tag = 'ul'
+
+ def __init__(self, content=None, **attrs):
+ self.content = []
+ self.attrs = attrs
+
+class Li(Element):
+ """
+ Step 7: Li class
+ """
+ list_element = ''
#
#
diff --git a/students/jeff_shabani/session07/test_html_render.py b/students/jeff_shabani/session07/test_html_render.py
index 559d69ed..a67097a5 100644
--- a/students/jeff_shabani/session07/test_html_render.py
+++ b/students/jeff_shabani/session07/test_html_render.py
@@ -14,22 +14,22 @@
# utility function for testing render methods
# needs to be used in multiple tests, so we write it once here.
-def render_result(element, ind=""):
- """
- calls the element's render method, and returns what got rendered as a
- string
- """
- # the StringIO object is a "file-like" object -- something that
- # provides the methods of a file, but keeps everything in memory
- # so it can be used to test code that writes to a file, without
- # having to actually write to disk.
- outfile = io.StringIO()
- # this so the tests will work before we tackle indentation
- if ind:
- element.render(outfile, ind)
- else:
- element.render(outfile)
- return outfile.getvalue()
+# def render_result(element, ind=""):
+# """
+# calls the element's render method, and returns what got rendered as a
+# string
+# """
+# # the StringIO object is a "file-like" object -- something that
+# # provides the methods of a file, but keeps everything in memory
+# # so it can be used to test code that writes to a file, without
+# # having to actually write to disk.
+# outfile = io.StringIO()
+# # this so the tests will work before we tackle indentation
+# if ind:
+# element.render(outfile, ind)
+# else:
+# element.render(outfile)
+# return outfile.getvalue()
########
# Step 1
@@ -243,24 +243,24 @@ def test_class_a():
assert f'link to google' in file_contents
-# def test_ul_li():
-# """ Tests that you can add unordered lists and list items """
-# with pytest.raises(TypeError):
-# ul = Ul("Should fail")
-#
-# ul = Ul(style='list-style-type:disc;')
-# ul.append(Li("List item 1"))
-# ul.append(Li("List item 2"))
-#
-# file_contents = render_result(ul).strip()
-# print(file_contents)
-#
-# assert file_contents.startswith("")
-# assert "List item 1" in file_contents
-# assert "List item 2" in file_contents
-# assert file_contents.count("- ") == 2
-# assert file_contents.count("
") == 2
+def test_ul_li():
+ """ Tests that you can add unordered lists and list items """
+ with pytest.raises(TypeError):
+ ul = Ul("Should fail")
+
+ ul = Ul(style='list-style-type:disc;')
+ ul.append(Li("List item 1"))
+ ul.append(Li("List item 2"))
+
+ file_contents = render_result(ul).strip()
+ print(file_contents)
+
+ assert file_contents.startswith("")
+ assert "List item 1" in file_contents
+ assert "List item 2" in file_contents
+ assert file_contents.count("- ") == 2
+ assert file_contents.count("
") == 2
# #####################
# # indentation testing
diff --git a/students/jeff_shabani/session07/test_html_render_unittest.py b/students/jeff_shabani/session07/test_html_render_unittest.py
index 731bb6ee..a8157548 100644
--- a/students/jeff_shabani/session07/test_html_render_unittest.py
+++ b/students/jeff_shabani/session07/test_html_render_unittest.py
@@ -27,9 +27,25 @@ class HTMLRenderTests(unittest.TestCase):
def test_a(self):
ca = A("http://google.com/", "link to google")
file_contents = render_result(ca)
+ expected = f'link to google'
print(file_contents)
- self.assertEqual(file_contents, f'link to google')
+ self.assertEqual(expected, f'link to google')
+
+ def test_ul(self):
+ ul = Ul(style='list-style-type:disc;')
+ ul.append(Li("List item 1"))
+ ul.append(Li("List item 2"))
+
+ file_contents = render_result(ul).strip()
+ print(file_contents)
+
+ self.assertEqual(file_contents[:3], "")
+ assert f'\nList item 1\n' in file_contents
+ assert f'\nList item 2\n' in file_contents
+
+
if __name__ == '__main__':
From 62420bee990ba3f169e922264294517d2196bdcc Mon Sep 17 00:00:00 2001
From: Rockwell70
Date: Fri, 8 Mar 2019 09:52:03 -0800
Subject: [PATCH 110/354] html_render update
---
.../jeff_shabani/session07/html_render.py | 66 ++++++++++---------
1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/students/jeff_shabani/session07/html_render.py b/students/jeff_shabani/session07/html_render.py
index 2a94ee57..6ea6c44b 100644
--- a/students/jeff_shabani/session07/html_render.py
+++ b/students/jeff_shabani/session07/html_render.py
@@ -5,9 +5,10 @@
"""
import functools
+
# This is the framework for the base class
class Element(object):
- indent = ' ' * 2
+ indent = ''
tag = 'html'
def __init__(self, content=None, **attrs):
@@ -28,15 +29,15 @@ def _end_tag(self):
def append(self, new_content):
self.content.append(new_content)
- def render(self, file_name, cur_indent=''):
+ def render(self, file_name, indent='', ind_count=0):
# Writes the opening tag
file_name.write(f'{self._front_tag()}\n')
for content_line in self.content:
if hasattr(content_line, 'render'):
- content_line.render(file_name)
+ content_line.render(file_name, indent, ind_count + 1)
else:
- file_name.write(f'{content_line}\n')
+ file_name.write(f'{self.indent}{indent}{content_line}\n')
file_name.write(f'{self._end_tag()}\n')
@@ -46,9 +47,10 @@ class Html(Element):
"""
tag = 'html'
- def render(self, file_name):
+ def render(self, file_name, indent="", ind_count=0):
+ self.indent = indent
file_name.write(f'\n')
- super().render(file_name)
+ super().render(file_name, indent)
class P(Element):
@@ -68,17 +70,20 @@ class for p tag
"""
Step 3: print on one line
"""
-class OneLineTag(Element):
+
+class OneLineTag(Element):
tag = 'Title'
- def render(self, file_name, cur_indent=''):
+ def render(self, file_name, indent="", ind_count=0):
"""
Renders elements on a single line.
- :param file_name:
- :param cur_indent:
+ :param file_name: Rendered object destination
+ :param indent: Indentation level
+ :param ind_count: Number of times indentation is to be applied
"""
- file_name.write(f'{self._front_tag()[:-1]} ')
+ self.indent = indent * ind_count
+ file_name.write(f'{self.indent}{self._front_tag()[:-1]} ')
for k, v in self.attrs.items():
file_name.write(f'{k}="{v}"')
file_name.write(f'>')
@@ -90,44 +95,47 @@ def append(self, new_content):
class Head(Element):
-
tag = "head"
-
"""
Step 5: Self closing tag
"""
+
class SelfClosingTag(Element):
tag = 'br'
def append(self, new_content):
raise NotImplementedError
- def render(self, file_name):
+ def render(self, file_name, indent="", ind_count=0):
"""
if conent is entered this tells user that self closing tags
can't have conent and resets the conent to an empty string.
"""
+ self.indent = indent * ind_count
+
if self.content:
raise TypeError
- file_name.write(f'{self._front_tag()[:-1]}')
+ file_name.write(f'{self.indent}{self._front_tag()[:-1]}')
for k, v in self.attrs.items():
file_name.write(f'{k.rjust(len(k) + 1)}="{v}" />')
+
"""
Step 6
"""
-class A(OneLineTag):
+class A(OneLineTag):
tag = 'a'
def __init__(self, link, content=None, **attrs):
- if not (content and link): raise TypeError
+ if not (content and link):
+ raise TypeError
attrs['href'] = link
super().__init__(content, **attrs)
@@ -143,23 +151,17 @@ def __init__(self, content=None, **attrs):
self.content = []
self.attrs = attrs
+
class Li(Element):
"""
Step 7: Li class
"""
list_element = ''
-#
-
-#
-# class Meta(SelfClosingTag):
-# """
-# add meta tag
-# """
-#
-# def __init__(self, content=None, tag = 'meta charset="UTF-8"'):
-# super().__init__(content, tag)
-
-# if __name__ == '__main__':
-#
-# olt = OneLineTag('this is william')
-# olt.render(olt, 'tag')
+
+
+class Meta(SelfClosingTag):
+ """
+ add meta tag
+ """
+
+ tag = 'meta'
From 19dd2d5a4790aaaa42ee704f6de1d337d271c533 Mon Sep 17 00:00:00 2001
From: Mahmood08
Date: Fri, 8 Mar 2019 10:10:15 -0800
Subject: [PATCH 111/354] updated Circle file
---
students/shirin_ak/Session08/Circle.py | 42 +++++++++++++++++++-------
1 file changed, 31 insertions(+), 11 deletions(-)
diff --git a/students/shirin_ak/Session08/Circle.py b/students/shirin_ak/Session08/Circle.py
index 8fa6a7bd..f80044d6 100644
--- a/students/shirin_ak/Session08/Circle.py
+++ b/students/shirin_ak/Session08/Circle.py
@@ -1,9 +1,11 @@
import math
+
class Circle():
def __init__(self, radius):
# STEP 1 The radius is a required parameter
self.radius = radius
+
# STEP 2 Add a 'diameter' property
@property
def diameter(self):
@@ -12,7 +14,7 @@ def diameter(self):
#STEP 3 set up the diameter property
@diameter.setter
def diameter(self, value):
- self.diameter = value
+ # self.diameter = value
self.radius = value/2
#STEP 4 Add an area property
@@ -23,23 +25,41 @@ def area(self):
# STEP 5 Add an “alternate constructor” that
#lets the user create a Circle directly with the diameter:
@classmethod
- def from_diameter(class_object, diameter):
- radius = diameter/2
- return class_object(radius)
+ def from_diameter(cls, diameter):
+ return cls(diameter/2)
#STEP 6 Add __str__ and __repr__ methods to your Circle class.
def __str__(self):
- return "Circle with radius: {:.6f}".format(self.radius)
+ return "Circle with radius: {:.4f}".format(self.radius)
def __repr__(self):
- return "Circle({r})".format(r=self.radius)
+ return "Circle({})".format(self.radius)
+
+
#STEP 7 Add two circles and multiply one by a number
- def ___add__(self, other):
- c1 = self.radius
- c2 = other.radius
- return Circle(c1+c2)
-# def __mul__(self, other):
+ def __add__(self, other):
+
+ return Circle(self.radius + other.radius)
+
+ def __mul__(self, other):
+ return Circle(self.radius * other)
+
+ #STEP 8 Add the ability to compare two circles
+ #Once the comparing is done, you should be able to sort a list of circles
+ def __greater__(self, other):
+ return self.radius > other.radius
+
+ def __less__(self, other):
+ return self.radius < other.radius
+
+ def __equal__(self, other):
+ return self.radius == other.radius
+
+ def sort_key(self):
+ return self.radius
+
+
From b86af91a06da7a129bd22be828304201f0410791 Mon Sep 17 00:00:00 2001
From: Mahmood08
Date: Fri, 8 Mar 2019 10:16:11 -0800
Subject: [PATCH 112/354] updated test_Circle file
---
students/shirin_ak/Session08/test_Circle.py | 58 ++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
diff --git a/students/shirin_ak/Session08/test_Circle.py b/students/shirin_ak/Session08/test_Circle.py
index 655c8287..98edc122 100644
--- a/students/shirin_ak/Session08/test_Circle.py
+++ b/students/shirin_ak/Session08/test_Circle.py
@@ -4,10 +4,12 @@
def test_radius():
+ """Test that the radius is the radius"""
c = Circle(4)
assert c.radius == 4
-def test_diameter():
+def test_diameter():
+ """ test that diameter is calculated correctly"""
c = Circle(4)
assert c.diameter == 8
@@ -19,11 +21,65 @@ def test_set_diameter():
assert c.radius == 5
def test_area():
+ """test that area gets calculated properly"""
c = Circle(1)
assert c.area == 3.141592653589793
def test_constructor():
+ """Test that the alternate constructor of from_diameter() works"""
+
c = Circle.from_diameter(4)
assert c.diameter == 4
assert c.radius == 2
+
+def test_str():
+ """Test that a Circle class object prints the string"""
+ c = Circle(4)
+ s = str(c)
+ assert s == "Circle with radius: 4.0000"
+
+def test_repr():
+ c = Circle(4)
+ d = repr(c)
+ assert d == 'Circle(4)'
+
+def test_add():
+ """
+ Testing that adding two Circle classes together yields a
+ Circle class with sums of their radius
+ """
+ c1 = Circle(2)
+ c2 = Circle(4)
+ print(c1 + c2)
+ assert(c1+c2) == Circle(6)
+
+def test_mul():
+ c1 = Circle(4)
+ assert (c1 * 3) == Circle(12)
+
+def test_less():
+ """ Test that the Circles can be compared with less than statement"""
+ c1 = Circle(3)
+ c2 = Circle(5)
+ assert c1.radius < c2.radius
+
+
+def test_greater():
+ """ Test that the Circles can be compared with greater than statement"""
+ c1 = Circle(5)
+ c2 = Circle(3)
+ assert c1.radius > c2.radius
+
+def test_equal():
+ """Test that the Circles can be compared with equal statement"""
+ c1 = Circle(6)
+ c2 = Circle(6)
+ assert c1.radius == c2.radius
+
+
+def test_sort_key():
+ circles = [Circle(6), Circle(8), Circle(7), Circle(4), Circle(0), Circle(2)]
+ circles.sort()
+ assert circles == [Circle(0), Circle(2), Circle(4), Circle(6), Circle(7), Circle(8)]
+
From ed692764c36ae05aa3c2e7a84104d772e783b3ce Mon Sep 17 00:00:00 2001
From: Rockwell70
Date: Fri, 8 Mar 2019 10:25:25 -0800
Subject: [PATCH 113/354] sparse_array
---
students/jeff_shabani/session08/sparse_array.py | 13 +++++++++++++
.../jeff_shabani/session08/test_sparse_array.py | 15 +++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 students/jeff_shabani/session08/sparse_array.py
create mode 100644 students/jeff_shabani/session08/test_sparse_array.py
diff --git a/students/jeff_shabani/session08/sparse_array.py b/students/jeff_shabani/session08/sparse_array.py
new file mode 100644
index 00000000..f11ffebf
--- /dev/null
+++ b/students/jeff_shabani/session08/sparse_array.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+class SparseArray(object):
+
+ def __init__(self, sequence):
+ self.sequence = sequence
+
+ def __repr__(self):
+ return f'{self.sequence}'
+
+spa = SparseArray([1,2,3])
+
+print(spa)
diff --git a/students/jeff_shabani/session08/test_sparse_array.py b/students/jeff_shabani/session08/test_sparse_array.py
new file mode 100644
index 00000000..d3fb7311
--- /dev/null
+++ b/students/jeff_shabani/session08/test_sparse_array.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import unittest
+
+from sparse_array import *
+
+class SparseArrayTest(unittest.TestCase):
+
+ def test_init(self):
+ spa = SparseArray([1, 2, 3])
+ self.assertEqual(repr(spa), '[1, 2, 3]')
+
+
+if __name__ == '__main__':
+ unittest.main()
From 75638bd6b860ab75361ea1a1ef316f35ae42b5ed Mon Sep 17 00:00:00 2001
From: dac2229
Date: Fri, 8 Mar 2019 14:43:55 -0800
Subject: [PATCH 114/354] start of lesson 08
---
students/daniel_carrasco/session08/circle.py | 10 +++++++
.../daniel_carrasco/session08/test_circle.py | 27 +++++++++++++++++++
2 files changed, 37 insertions(+)
create mode 100644 students/daniel_carrasco/session08/circle.py
create mode 100644 students/daniel_carrasco/session08/test_circle.py
diff --git a/students/daniel_carrasco/session08/circle.py b/students/daniel_carrasco/session08/circle.py
new file mode 100644
index 00000000..00494d6a
--- /dev/null
+++ b/students/daniel_carrasco/session08/circle.py
@@ -0,0 +1,10 @@
+class Circle():
+
+ def __init__(self,the_radius):
+ self.radius = the_radius
+ self.diameter = self.radius*2
+
+
+c = Circle(4)
+print(c.radius)
+print(c.diameter)
\ No newline at end of file
diff --git a/students/daniel_carrasco/session08/test_circle.py b/students/daniel_carrasco/session08/test_circle.py
new file mode 100644
index 00000000..e665754d
--- /dev/null
+++ b/students/daniel_carrasco/session08/test_circle.py
@@ -0,0 +1,27 @@
+import io
+import pytest
+
+from circle import *
+
+def test_init():
+ """
+ This only tests that it can be initialized with and without
+ some content -- but it's a start
+ """
+ c = Circle(4)
+
+
+def test_radius():
+
+ "check to see if it outputs correct radius"
+ c = Circle(5)
+ # making sure radius outputs correctly.
+ assert c.radius == 5
+
+def test_diameter():
+
+ "check to see if it outputs correct radius"
+ c = Circle(5)
+ # making sure radius outputs correctly.
+ assert c.diameter == 10
+ assert c.diameter == c.radius*2
\ No newline at end of file
From 757a1e09f2fc9080eca0422bf2ae83b7a8ddb4e8 Mon Sep 17 00:00:00 2001
From: JRockwell70
Date: Fri, 8 Mar 2019 18:57:17 -0800
Subject: [PATCH 115/354] session 7
---
.../session07/test_html_render.py | 186 +++++++++---------
1 file changed, 93 insertions(+), 93 deletions(-)
diff --git a/students/jeff_shabani/session07/test_html_render.py b/students/jeff_shabani/session07/test_html_render.py
index 9f6bc769..235bdb8e 100644
--- a/students/jeff_shabani/session07/test_html_render.py
+++ b/students/jeff_shabani/session07/test_html_render.py
@@ -55,123 +55,123 @@ def test_append():
e.append("some more text")
-# def test_render_element():
-# """
-# Tests whether the Element can render two pieces of text
-# So it is also testing that the append method works correctly.
-#
-# It is not testing whether indentation or line feeds are correct.
-# """
-# e = Element("this is some text")
-# e.append("and this is some more text")
-#
-# # This uses the render_results utility above
-# file_contents = render_result(e).strip()
-#
-# # making sure the content got in there.
-# assert("this is some text") in file_contents
-# assert("and this is some more text") in file_contents
-#
-# # make sure it's in the right order
-# assert file_contents.index("this is") < file_contents.index("and this")
-#
-# # making sure the opening and closing tags are right.
-# assert file_contents.startswith("")
-# assert file_contents.endswith("")
+def test_render_element():
+ """
+ Tests whether the Element can render two pieces of text
+ So it is also testing that the append method works correctly.
-# # Uncomment this one after you get the one above to pass
-# # Does it pass right away?
-# def test_render_element2():
-# """
-# Tests whether the Element can render two pieces of text
-# So it is also testing that the append method works correctly.
+ It is not testing whether indentation or line feeds are correct.
+ """
+ e = Element("this is some text")
+ e.append("and this is some more text")
-# It is not testing whether indentation or line feeds are correct.
-# """
-# e = Element()
-# e.append("this is some text")
-# e.append("and this is some more text")
+ # This uses the render_results utility above
+ file_contents = render_result(e).strip()
-# # This uses the render_results utility above
-# file_contents = render_result(e).strip()
+ # making sure the content got in there.
+ assert("this is some text") in file_contents
+ assert("and this is some more text") in file_contents
-# # making sure the content got in there.
-# assert("this is some text") in file_contents
-# assert("and this is some more text") in file_contents
+ # make sure it's in the right order
+ assert file_contents.index("this is") < file_contents.index("and this")
-# # make sure it's in the right order
-# assert file_contents.index("this is") < file_contents.index("and this")
+ # making sure the opening and closing tags are right.
+ assert file_contents.startswith("")
+ assert file_contents.endswith("")
-# # making sure the opening and closing tags are right.
-# assert file_contents.startswith("")
-# assert file_contents.endswith("")
+# Uncomment this one after you get the one above to pass
+# Does it pass right away?
+def test_render_element2():
+ """
+ Tests whether the Element can render two pieces of text
+ So it is also testing that the append method works correctly.
+ It is not testing whether indentation or line feeds are correct.
+ """
+ e = Element()
+ e.append("this is some text")
+ e.append("and this is some more text")
+ # This uses the render_results utility above
+ file_contents = render_result(e).strip()
-# # ########
-# # # Step 2
-# # ########
+ # making sure the content got in there.
+ assert("this is some text") in file_contents
+ assert("and this is some more text") in file_contents
-# # tests for the new tags
-# def test_html():
-# e = Html("this is some text")
-# e.append("and this is some more text")
+ # make sure it's in the right order
+ assert file_contents.index("this is") < file_contents.index("and this")
-# file_contents = render_result(e).strip()
+ # making sure the opening and closing tags are right.
+ assert file_contents.startswith("")
+ assert file_contents.endswith("")
-# assert("this is some text") in file_contents
-# assert("and this is some more text") in file_contents
-# print(file_contents)
-# assert file_contents.endswith("")
-# def test_body():
-# e = Body("this is some text")
-# e.append("and this is some more text")
+# ########
+# # Step 2
+# ########
-# file_contents = render_result(e).strip()
+# tests for the new tags
+def test_html():
+ e = Html("this is some text")
+ e.append("and this is some more text")
-# assert("this is some text") in file_contents
-# assert("and this is some more text") in file_contents
+ file_contents = render_result(e).strip()
-# assert file_contents.startswith("")
-# assert file_contents.endswith("")
+ assert("this is some text") in file_contents
+ assert("and this is some more text") in file_contents
+ print(file_contents)
+ assert file_contents.endswith("