Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unit Tests for Counters Lesson in Repetitions Chapter #360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
25 changes: 25 additions & 0 deletions _sources/lectures/TWP15/TWP15_3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ Algunos ejercicios
pero esta vez solo los números impares.

~~~~
def print_odd_numbers(n):


====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_odd_numbers(10), [1, 3, 5, 7, 9], "Esperado [1, 3, 5, 7, 9]")
self.assertEqual(print_odd_numbers(1), [1], "Esperado [1]")
self.assertEqual(print_odd_numbers(0), [], "Esperado []")

myTests().main()


.. activecode:: ac_l15_3e
Expand All @@ -59,3 +73,14 @@ Algunos ejercicios
Escriba un programa que imprima los primeros 10 múltiplos de 3.

~~~~
def print_multiples_of_3():

====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_multiples_of_3(), [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], "Esperado [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]")

myTests().main()
26 changes: 25 additions & 1 deletion _sources/lectures/TWP15/TWP15_3_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,35 @@ Some Exercises
the user, but this time only the odd numbers.

~~~~
def print_odd_numbers(n):


====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_odd_numbers(10), [1, 3, 5, 7, 9], "Expected [1, 3, 5, 7, 9]")
self.assertEqual(print_odd_numbers(1), [1], "Expected [1]")
self.assertEqual(print_odd_numbers(0), [], "Expected []")

myTests().main()

.. activecode:: ac_l15_3e_en
:nocodelens:

Write a program that prints the first 10 multiples of 3.

~~~~
~~~~
def print_multiples_of_3():

====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_multiples_of_3(), [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], "Expected [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]")

myTests().main()
Loading