Skip to content

Commit 8fec75b

Browse files
committed
1 parent 3be920c commit 8fec75b

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

exercises/15-Techno_beat/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
You are working with a DJ and he needs a program that can create a beats for his songs.
33

44
# 📝Instructions:
5-
1. Create a function lyricsGenerator that receives a list
5+
1. Create a function lyrics_generator that receives a list
66
The list passed to the function will be something like this:
77
[0,0,1,1,0,0,0]
88
2. For each Zero you will add to the string 'Boom'

exercises/15-Techno_beat/test.py

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,20 @@
1-
import io
2-
import os
3-
import sys
4-
sys.stdout = buffer = io.StringIO()
1+
import io, sys, pytest, os, re
2+
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
53

64

7-
import app
8-
import pytest
5+
@pytest.mark.it("Create the function lyrics_generator")
6+
def test_variable_exists(app):
7+
try:
8+
app.lyrics_generator
9+
except AttributeError:
10+
raise AttributeError("The function lyrics_generator should exist on app.py")
911

10-
@pytest.mark.it("Create a function lyrics_generator")
11-
def test_function():
12-
f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py')
13-
content = f.read()
14-
assert content.find("lyrics_generator")
15-
16-
17-
@pytest.mark.it("Use for loop")
18-
def test_for():
19-
f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py')
20-
content = f.read()
21-
assert content.find("for")
22-
23-
@pytest.mark.it("Use conditionals if/elif/else")
24-
def test_conditinal():
25-
f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py')
26-
content = f.read()
27-
assert content.find("for")
28-
29-
@pytest.mark.it("Store the value in the variable that you have to return")
30-
def test_append():
31-
f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py')
32-
content = f.read()
33-
assert content.find("append")
3412

3513
@pytest.mark.it("Print the strings like song")
36-
def test_output():
37-
captured = buffer.getvalue()
38-
assert "['boom', 'boom', 'Drop the base', 'Drop the base', 'boom', 'boom', 'boom']\n['boom', 'boom', 'Drop the base', 'Drop the base', 'Drop the base', '!!!Break the base', 'boom', 'boom', 'boom']\n['boom', 'boom', 'boom']\n['Drop the base', 'boom', 'Drop the base']\n['Drop the base', 'Drop the base', 'Drop the base', '!!!Break the base']\n" in captured
14+
def test_output(capsys, app):
15+
import app
16+
captured = capsys.readouterr()
17+
assert 'Boom Boom Drop the base Drop the base Boom Boom Boom \nBoom Boom Drop the base Drop the base Drop the base !!!Break the base!!! Boom Boom Boom \nBoom Boom Boom \nDrop the base Boom Drop the base \nDrop the base !!!Break the base!!! Drop the base !!!Break the base!!! Drop the base !!!Break the base!!! \n' in captured.out
3918

4019

4120

0 commit comments

Comments
 (0)