Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion musical_notes/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from musical_notes.notes_test import game_notes, random_image
from musical_notes.notes_test import game_notes
Binary file modified musical_notes/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified musical_notes/__pycache__/notes_test.cpython-36.pyc
Binary file not shown.
14 changes: 5 additions & 9 deletions musical_notes/notes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
from PIL import ImageTk, Image
from random import randint

def imagegen(numb, imagelist):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add some dostring here to what it does and what parameters are needed and what it returns.
For example:

def imagegen(numb, imagelist) -> musical_notes.........: ( --> shows what it returns)
""" Some info of what this function does
:param numb: info about parameter
:type numb: info of what kind of parameter it is
... etc
... etc
"""

return "musical_notes/musicalnotes/" + imagelist[numb]+".png"

class random_image:
# Random number generator:
def __init__ (self, inputlist):
randnumb = randint(0, len(inputlist)-1)
return randnumb


class game_notes:
Expand Down Expand Up @@ -41,13 +38,12 @@ def start_note_practice ():
notes_list = ['C_test', 'C1_test', 'D_test', 'D1_test', 'E_test', 'E1_test', 'F_test', 'F1_test', 'G_test', 'G1_test', 'A_test', 'A1_test', 'B_test', 'B1_test']

# Random number generator:
def randimg (self, inputlist):
randnumb = randint(0, len(inputlist)-1)
randnote = "musical_notes/musicalnotes/" + inputlist[randnumb]+".png"
randnumb = randint(0, len(notes_list)-1)
randnote = "musical_notes/musicalnotes/" + notes_list[randnumb]+".png"

# Creating images:
global note_image
note_image = ImageTk.PhotoImage(Image.open(randimg(notes_list)))
note_image = ImageTk.PhotoImage(Image.open(randnote))
show_note = Label(start_note_practice_frame, image=note_image)
show_note.pack(pady=15)

Expand Down
Binary file modified musical_notes/test/__pycache__/test_notes.cpython-36.pyc
Binary file not shown.
16 changes: 11 additions & 5 deletions musical_notes/test/test_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
import tkinter


from musical_notes.notes_test import game_notes
from musical_notes.notes_test import game_notes, imagegen


class TestWidget(self):
def test_entry_widget(self):
widget=Widget('answer_box')
self.assertEqual(widget.size(), (50, 50))

class TestRandomNote(unittest.TestCase):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem ditto, add some dostrings and parameter info

def test_notepick(self):
self.note1 = imagegen(6, ['C_test', 'C1_test', 'D_test', 'D1_test', 'E_test', 'E1_test', 'F_test', 'F1_test', 'G_test', 'G1_test', 'A_test', 'A1_test', 'B_test', 'B1_test'])
self.note2 = imagegen(10, ['C_test', 'C1_test', 'D_test', 'D1_test', 'E_test', 'E1_test', 'F_test', 'F1_test', 'G_test', 'G1_test', 'A_test', 'A1_test', 'B_test', 'B1_test'])
self.note3 = imagegen(2, ['C_test', 'C1_test', 'D_test', 'D1_test', 'E_test', 'E1_test', 'F_test', 'F1_test', 'G_test', 'G1_test', 'A_test', 'A1_test', 'B_test', 'B1_test'])

self.assertEqual(self.note1, "musical_notes/musicalnotes/F_test.png")
self.assertEqual(self.note2, "musical_notes/musicalnotes/A_test.png")
self.assertEqual(self.note3, "musical_notes/musicalnotes/D_test.png")

if __name__ == '__main__':
unittest.main()
Expand Down