Skip to content

Commit

Permalink
Added Unit Tests for Counters in Repetitions Chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
its-ChaTTy committed Apr 15, 2024
1 parent 912c7df commit 8abbd76
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
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()

0 comments on commit 8abbd76

Please sign in to comment.