testhellos 0.1.0__tar.gz → 0.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testhellos
3
- Version: 0.1.0
3
+ Version: 0.3.0
4
4
  Summary: A collection of reusable Python utilities
5
5
  Author: Adarsh Kumar
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "testhellos"
7
- version = "0.1.0"
7
+ version = "0.3.0"
8
8
  description = "A collection of reusable Python utilities"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -0,0 +1,20 @@
1
+ from .math_utils import add as add
2
+ from .math_utils import divide as divide
3
+ from .math_utils import multiply as multiply
4
+ from .math_utils import subtract as subtract
5
+ from .string_utils import capitalize_words as capitalize_words
6
+ from .string_utils import count_words as count_words
7
+ from .string_utils import reverse_string as reverse_string
8
+
9
+ __version__ = "0.3.0"
10
+
11
+ __all__ = [
12
+ "__version__",
13
+ "add",
14
+ "capitalize_words",
15
+ "count_words",
16
+ "divide",
17
+ "multiply",
18
+ "reverse_string",
19
+ "subtract",
20
+ ]
@@ -0,0 +1,39 @@
1
+ from numbers import Real
2
+
3
+
4
+ def _validate_number(value: Real, name: str) -> None:
5
+ """Validate that a value is a real number, excluding booleans."""
6
+ if isinstance(value, bool) or not isinstance(value, Real):
7
+ raise TypeError(f"{name} must be a real number")
8
+
9
+
10
+ def add(a: Real, b: Real) -> Real:
11
+ """Return the sum of two numbers."""
12
+ _validate_number(a, "a")
13
+ _validate_number(b, "b")
14
+ return a + b
15
+
16
+
17
+ def subtract(a: Real, b: Real) -> Real:
18
+ """Return the difference between two numbers."""
19
+ _validate_number(a, "a")
20
+ _validate_number(b, "b")
21
+ return a - b
22
+
23
+
24
+ def multiply(a: Real, b: Real) -> Real:
25
+ """Return the product of two numbers."""
26
+ _validate_number(a, "a")
27
+ _validate_number(b, "b")
28
+ return a * b
29
+
30
+
31
+ def divide(a: Real, b: Real) -> float:
32
+ """Divide two numbers. Raise ValueError if divisor is zero."""
33
+ _validate_number(a, "a")
34
+ _validate_number(b, "b")
35
+
36
+ if b == 0:
37
+ raise ValueError("Cannot divide by zero")
38
+
39
+ return a / b
@@ -10,4 +10,4 @@ def count_words(text):
10
10
 
11
11
  def capitalize_words(text):
12
12
  """Capitalize each word."""
13
- return text.title()
13
+ return text.title()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testhellos
3
- Version: 0.1.0
3
+ Version: 0.3.0
4
4
  Summary: A collection of reusable Python utilities
5
5
  Author: Adarsh Kumar
6
6
  License-Expression: MIT
@@ -0,0 +1,22 @@
1
+ import pytest
2
+
3
+ from testhellos import add, divide
4
+
5
+
6
+ def test_add_floats():
7
+ assert add(2.5, 3.5) == 6.0
8
+
9
+
10
+ def test_add_invalid_input():
11
+ with pytest.raises(TypeError):
12
+ add("10", 20)
13
+
14
+
15
+ def test_boolean_is_not_a_number():
16
+ with pytest.raises(TypeError):
17
+ add(True, 10)
18
+
19
+
20
+ def test_divide_by_zero():
21
+ with pytest.raises(ValueError):
22
+ divide(10, 0)
@@ -1,8 +1,4 @@
1
- from testhellos import (
2
- reverse_string,
3
- count_words,
4
- capitalize_words
5
- )
1
+ from testhellos import capitalize_words, count_words, reverse_string
6
2
 
7
3
 
8
4
  def test_reverse_string():
@@ -22,4 +18,4 @@ def test_capitalize_words():
22
18
 
23
19
 
24
20
  def test_reverse_empty_string():
25
- assert reverse_string("") == ""
21
+ assert reverse_string("") == ""
@@ -1,9 +0,0 @@
1
- from .math_utils import add, subtract, multiply, divide
2
-
3
- from .string_utils import (
4
- reverse_string,
5
- count_words,
6
- capitalize_words
7
- )
8
-
9
- __version__ = "0.1.0"
@@ -1,22 +0,0 @@
1
- def add(a, b):
2
- """Return the sum of two numbers."""
3
- return a + b
4
-
5
-
6
- def subtract(a, b):
7
- """Return the difference between two numbers."""
8
- return a - b
9
-
10
-
11
- def multiply(a, b):
12
- """Return the product of two numbers."""
13
- return a * b
14
-
15
-
16
- def divide(a, b):
17
- """Divide two numbers."""
18
-
19
- if b == 0:
20
- raise ValueError("Cannot divide by zero")
21
-
22
- return a / b
@@ -1,24 +0,0 @@
1
- import pytest
2
-
3
- from testhellos import add, subtract, multiply, divide
4
-
5
-
6
- def test_add():
7
- assert add(10, 20) == 30
8
-
9
-
10
- def test_subtract():
11
- assert subtract(20, 10) == 10
12
-
13
-
14
- def test_multiply():
15
- assert multiply(5, 5) == 25
16
-
17
-
18
- def test_divide():
19
- assert divide(20, 4) == 5
20
-
21
-
22
- def test_divide_by_zero():
23
- with pytest.raises(ValueError):
24
- divide(10, 0)
File without changes
File without changes