damebasics 0.2.2__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {damebasics-0.2.2 → damebasics-0.2.4}/PKG-INFO +1 -1
  2. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_files.py +16 -4
  3. damebasics-0.2.4/damebasics/tests/test_lambda.py +79 -0
  4. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_network.py +8 -6
  5. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics.egg-info/PKG-INFO +1 -1
  6. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics.egg-info/SOURCES.txt +1 -0
  7. {damebasics-0.2.2 → damebasics-0.2.4}/pyproject.toml +1 -1
  8. {damebasics-0.2.2 → damebasics-0.2.4}/LICENSE +0 -0
  9. {damebasics-0.2.2 → damebasics-0.2.4}/README.md +0 -0
  10. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/files/buggy.csv +0 -0
  11. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/files/fiall.csv +0 -0
  12. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/files/pg1513.txt +0 -0
  13. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/files/tmp.txt +0 -0
  14. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/files/tmp2.txt +0 -0
  15. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/runtests.sh +0 -0
  16. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/calculator.py +0 -0
  17. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/damebasics.py +0 -0
  18. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/factorial.py +0 -0
  19. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/fib.py +0 -0
  20. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/fraction.py +0 -0
  21. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/hanoi.py +0 -0
  22. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/primes.py +0 -0
  23. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/src/queuelist.py +0 -0
  24. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/__init__.py +0 -0
  25. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_arithmetics.py +0 -0
  26. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_collections.py +0 -0
  27. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_control_structures.py +0 -0
  28. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_date.py +0 -0
  29. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_dict.py +0 -0
  30. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_lists.py +0 -0
  31. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_poo.py +0 -0
  32. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_set.py +0 -0
  33. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_strings.py +0 -0
  34. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics/tests/test_tuples.py +0 -0
  35. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics.egg-info/dependency_links.txt +0 -0
  36. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics.egg-info/entry_points.txt +0 -0
  37. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics.egg-info/requires.txt +0 -0
  38. {damebasics-0.2.2 → damebasics-0.2.4}/damebasics.egg-info/top_level.txt +0 -0
  39. {damebasics-0.2.2 → damebasics-0.2.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: damebasics
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Learning basic control structures and basic datastructures from Tests by David Arroyo Menéndez'
5
5
  Author-email: David Arroyo Menéndez <davidam@gmail.com>
6
6
  Maintainer-email: David Arroyo Menéndez <davidam@gmail.com>
@@ -8,26 +8,38 @@
8
8
  # it under the terms of the GNU General Public License as published by
9
9
  # the Free Software Foundation; either version 3, or (at your option)
10
10
  # any later version.
11
- #
11
+ #
12
12
  # This file is distributed in the hope that it will be useful,
13
13
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
15
  # GNU General Public License for more details.
16
- #
16
+ #
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with DameBasics; see the file GPL.txt. If not, write to
19
- # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
+ # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
20
  # Boston, MA 02110-1301 USA,
21
21
 
22
22
  import unittest
23
23
  from src.damebasics import DameBasics
24
24
  import collections
25
+ import os
25
26
  collections.Callable = collections.abc.Callable
26
27
 
27
28
  # from pprint import pprint
28
29
 
29
30
  class TddInPythonExample(unittest.TestCase):
30
31
 
32
+ def test_files_touch(self):
33
+ fname = "files/touch.txt"
34
+ fhandle = open(fname, 'a')
35
+ try:
36
+ os.utime(fname, None)
37
+ finally:
38
+ fhandle.close()
39
+ self.assertTrue(os.path.exists(fname))
40
+ self.assertTrue(os.path.isfile(fname))
41
+ self.assertFalse(os.path.isdir(fname))
42
+
31
43
  def test_files_write_returns_correct_result(self):
32
44
  fo = open("files/tmp.txt", "w")
33
45
  fo.write("Gora python\n");
@@ -62,4 +74,4 @@ class TddInPythonExample(unittest.TestCase):
62
74
  self.assertTrue(bool0)
63
75
  testpath1 = "files/buggy.csv"
64
76
  bool1 = db.eq_columns_in_csv(testpath1)
65
- self.assertFalse(bool1)
77
+ self.assertFalse(bool1)
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # Copyright (C) 2026 David Arroyo Menéndez
5
+
6
+ # Author: David Arroyo Menéndez <davidam@gmail.com>
7
+ # Maintainer: David Arroyo Menéndez <davidam@gmail.com>
8
+
9
+ # This file is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation; either version 3, or (at your option)
12
+ # any later version.
13
+
14
+ # This file is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with damebasics; see the file LICENSE. If not, write to
21
+ # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
+ # Boston, MA 02110-1301 USA,
23
+
24
+ from unittest import TestCase
25
+ from functools import reduce
26
+
27
+ class TestLambda(TestCase):
28
+
29
+ def test_lambda_basic(self):
30
+ x = lambda a, b, c : a + b + c
31
+ self.assertEqual(x(5, 6, 4), 15)
32
+ x = lambda a, b : a * b
33
+ self.assertEqual(x(5, 6), 30)
34
+ x = lambda x: 2 ** x
35
+ self.assertEqual(x(3), 8)
36
+
37
+ def test_lambda_map_power(self):
38
+ x = list(map(lambda x: 2 ** x, range(10)))
39
+ self.assertEqual(x, [1, 2, 4, 8, 16, 32, 64, 128, 256, 512])
40
+
41
+ def test_lambda_map_upper(self):
42
+ a = ["apple", "banana", "cherry"]
43
+ # Use map() with lambda to convert each string to uppercase
44
+ b = map(lambda x: x.upper(), a)
45
+ # Convert the map object to a list and print it
46
+ result = list(b)
47
+ self.assertEqual(result, ["APPLE", "BANANA", "CHERRY"])
48
+
49
+ def test_lambda_map_multiply(self):
50
+ a = [1, 2, 3, 4, 5]
51
+ result = list(map(lambda x: x * 3, a))
52
+ print(result)
53
+ self.assertEqual(result, [3, 6, 9, 12, 15])
54
+
55
+ def test_lambda_map_and_tuples(self):
56
+ nums = (1, 2, 3)
57
+ result = tuple(map(lambda x: x + 1, nums))
58
+ self.assertEqual(result, (2, 3, 4))
59
+
60
+ def test_lambda_reduce_strings(self):
61
+ from functools import reduce
62
+ a = ["Geeks", "for", "Geeks"]
63
+ result = reduce(lambda x, y: x + " " + y, a)
64
+ self.assertEqual(result, "Geeks for Geeks")
65
+
66
+ def test_lambda_reduce_integers(self):
67
+ a = [2, 4, 6, 8]
68
+ result = reduce(lambda x, y: x + y, a)
69
+ self.assertEqual(result, 20)
70
+
71
+ def test_lambda_reduce_highest(self):
72
+ a = [5, 9, 3, 12, 7]
73
+ result = reduce(lambda x, y: x if x > y else y, a)
74
+ self.assertEqual(result, 12)
75
+
76
+ def test_lambda_filter(self):
77
+ c = [1, 2, 3, 4, 5, 6]
78
+ even = filter(lambda x: x % 2 == 0, c)
79
+ self.assertEqual([2, 4, 6], list(even))
@@ -23,6 +23,7 @@
23
23
 
24
24
  import unittest
25
25
  import socket
26
+ import os
26
27
  import re
27
28
  from pprint import pprint
28
29
  # fix for MacOS using nose
@@ -32,10 +33,13 @@ collections.Callable = collections.abc.Callable
32
33
 
33
34
  class TddInPythonExample(unittest.TestCase):
34
35
 
36
+ def test_network_getpid(self):
37
+ self.assertTrue(os.getpid() > 0)
38
+
35
39
  def test_network_socket_gethostbyname(self):
36
40
  ip = socket.gethostbyname('localhost')
37
41
  self.assertEqual(ip, '127.0.0.1')
38
-
42
+
39
43
  def test_network_socket_connect(self):
40
44
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
41
45
  try:
@@ -43,20 +47,18 @@ class TddInPythonExample(unittest.TestCase):
43
47
  self.assertTrue("<socket.socket" in str(s))
44
48
  except:
45
49
  pprint("Please, to check the Internet connection")
46
-
50
+
47
51
  def test_network_socket_gethostbyaddr(self):
48
52
  g = socket.gethostbyaddr('127.0.0.1')
49
53
  res = ('localhost', [], ['127.0.0.1'])
50
54
  self.assertEqual(g, res)
51
55
 
52
56
 
53
- def test_network_socket_getservbyname(self):
57
+ def test_network_socket_getservbyname(self):
54
58
  proto = "tcp"
55
59
  self.assertEqual(socket.getservbyport(80,proto), "http")
56
60
  self.assertEqual(socket.getservbyname("ftp",proto), 21)
57
61
  self.assertEqual(socket.getservbyname("http",proto), 80)
58
62
  self.assertEqual(socket.getservbyname("https",proto), 443)
59
63
  self.assertEqual(socket.getservbyport(21,proto), "ftp")
60
- self.assertEqual(socket.getservbyport(443,proto), "https")
61
-
62
-
64
+ self.assertEqual(socket.getservbyport(443,proto), "https")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: damebasics
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Learning basic control structures and basic datastructures from Tests by David Arroyo Menéndez'
5
5
  Author-email: David Arroyo Menéndez <davidam@gmail.com>
6
6
  Maintainer-email: David Arroyo Menéndez <davidam@gmail.com>
@@ -28,6 +28,7 @@ damebasics/tests/test_control_structures.py
28
28
  damebasics/tests/test_date.py
29
29
  damebasics/tests/test_dict.py
30
30
  damebasics/tests/test_files.py
31
+ damebasics/tests/test_lambda.py
31
32
  damebasics/tests/test_lists.py
32
33
  damebasics/tests/test_network.py
33
34
  damebasics/tests/test_poo.py
@@ -17,7 +17,7 @@ name = "damebasics" # Required
17
17
  #
18
18
  # For a discussion on single-sourcing the version, see
19
19
  # https://packaging.python.org/guides/single-sourcing-package-version/
20
- version = "0.2.2" # Required
20
+ version = "0.2.4" # Required
21
21
 
22
22
  # This is a one-line description or tagline of what your project does. This
23
23
  # corresponds to the "Summary" metadata field:
File without changes
File without changes
File without changes