nepali 1.0.1__py3-none-any.whl → 1.1.0__py3-none-any.whl
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.
- nepali/{datetime/constants.py → constants.py} +15 -2
- nepali/datetime/__init__.py +1 -1
- nepali/datetime/_datetime.py +12 -13
- nepali/datetime/_formatter.py +3 -2
- nepali/datetime/_humanize.py +14 -29
- nepali/datetime/_nepalimonth.py +7 -6
- nepali/datetime/_nepaliweek.py +4 -3
- nepali/datetime/parser/__init__.py +1 -1
- nepali/datetime/parser/_parser.py +7 -9
- nepali/datetime/parser/validators.py +162 -78
- nepali/datetime/utils.py +1 -0
- nepali/locations/__init__.py +1 -1
- nepali/locations/_locations.py +1 -1
- nepali/locations/utils.py +1 -2
- nepali/number/__init__.py +1 -1
- nepali/number/_nepalinumber.py +26 -12
- nepali/number/_number.py +1 -6
- nepali/number/utils.py +1 -2
- nepali/phone_number.py +2 -3
- nepali/templatetags/nepalidatetime.py +37 -0
- nepali/templatetags/nepalinumber.py +26 -0
- nepali/tests/test_datetime.py +3 -5
- nepali/tests/test_humanize.py +1 -2
- nepali/tests/test_locations.py +3 -3
- nepali/tests/test_number.py +35 -33
- nepali/tests/test_phone_number.py +3 -3
- nepali/tests/test_timezone.py +6 -5
- nepali/timezone.py +5 -3
- nepali/utils.py +1 -1
- {nepali-1.0.1.dist-info → nepali-1.1.0.dist-info}/METADATA +9 -83
- nepali-1.1.0.dist-info/RECORD +46 -0
- nepali-1.0.1.dist-info/RECORD +0 -46
- {nepali-1.0.1.dist-info → nepali-1.1.0.dist-info}/LICENSE +0 -0
- {nepali-1.0.1.dist-info → nepali-1.1.0.dist-info}/WHEEL +0 -0
- {nepali-1.0.1.dist-info → nepali-1.1.0.dist-info}/top_level.txt +0 -0
nepali/locations/utils.py
CHANGED
nepali/number/__init__.py
CHANGED
nepali/number/_nepalinumber.py
CHANGED
|
@@ -3,6 +3,7 @@ Contains the class for the nepalinumber feature
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from typing import Any, Tuple, Type, Union
|
|
6
|
+
|
|
6
7
|
from .utils import NP_NUMBERS, NP_NUMBERS_SET, english_to_nepali
|
|
7
8
|
|
|
8
9
|
|
|
@@ -19,10 +20,23 @@ class nepalinumber:
|
|
|
19
20
|
"""
|
|
20
21
|
self.__value = self.__parse(value)
|
|
21
22
|
|
|
22
|
-
def
|
|
23
|
-
|
|
23
|
+
def get_parse_exception(
|
|
24
|
+
self, obj: object, ex_class: Type[Exception] = ValueError
|
|
25
|
+
) -> Exception:
|
|
26
|
+
"""
|
|
27
|
+
Returns the exception object to be raised when the parse is failed.
|
|
28
|
+
The methods also sets a proper message to the exception class.
|
|
29
|
+
|
|
30
|
+
:param obj: Object that is failed during the parse
|
|
31
|
+
:type obj: object
|
|
32
|
+
:param ex_class: Exception class type to be returned, defaults to ValueError
|
|
33
|
+
:type ex_class: Type[Exception], optional
|
|
34
|
+
:return: Exception object to be raised
|
|
35
|
+
:rtype: Exception
|
|
36
|
+
"""
|
|
37
|
+
return ex_class(
|
|
24
38
|
f"could not convert {obj.__class__.__name__} to {self.__class__.__name__}: '{obj}'"
|
|
25
|
-
)
|
|
39
|
+
)
|
|
26
40
|
|
|
27
41
|
def __parse(self, value: Any) -> Union[int, float]:
|
|
28
42
|
"""
|
|
@@ -61,10 +75,10 @@ class nepalinumber:
|
|
|
61
75
|
|
|
62
76
|
:raises ValueError: If the value is invalid
|
|
63
77
|
"""
|
|
64
|
-
result = 0
|
|
78
|
+
result: float = 0
|
|
65
79
|
sign = 1
|
|
66
80
|
decimal_found = False
|
|
67
|
-
decimal_place = 1
|
|
81
|
+
decimal_place: float = 1
|
|
68
82
|
i = 0
|
|
69
83
|
|
|
70
84
|
# for negative sign
|
|
@@ -77,7 +91,7 @@ class nepalinumber:
|
|
|
77
91
|
if value[i] == ".":
|
|
78
92
|
if decimal_found:
|
|
79
93
|
# decimal was already found
|
|
80
|
-
self.
|
|
94
|
+
raise self.get_parse_exception(value) from None
|
|
81
95
|
decimal_found = True
|
|
82
96
|
i += 1
|
|
83
97
|
continue
|
|
@@ -86,7 +100,7 @@ class nepalinumber:
|
|
|
86
100
|
if digit < 0 or digit > 9:
|
|
87
101
|
# checking nepali character
|
|
88
102
|
if value[i] not in NP_NUMBERS_SET:
|
|
89
|
-
self.
|
|
103
|
+
raise self.get_parse_exception(value) from None
|
|
90
104
|
digit = NP_NUMBERS.index(value[i])
|
|
91
105
|
|
|
92
106
|
if decimal_found:
|
|
@@ -113,7 +127,7 @@ class nepalinumber:
|
|
|
113
127
|
return self.__parse_str(str(obj))
|
|
114
128
|
except (ValueError, TypeError):
|
|
115
129
|
# object conversion must raise TypeError if fails
|
|
116
|
-
self.
|
|
130
|
+
raise self.get_parse_exception(obj, ex_class=TypeError) from None
|
|
117
131
|
|
|
118
132
|
def __convert_or_return(self, obj) -> Union["nepalinumber", object]:
|
|
119
133
|
"""
|
|
@@ -184,7 +198,7 @@ class nepalinumber:
|
|
|
184
198
|
Checks if nepalinumber is equal to another object
|
|
185
199
|
|
|
186
200
|
:param other: The other number/object which is to be checked for
|
|
187
|
-
equality
|
|
201
|
+
equality against nepalinumber
|
|
188
202
|
:return: True if equal else False
|
|
189
203
|
"""
|
|
190
204
|
if isinstance(other, nepalinumber):
|
|
@@ -197,7 +211,7 @@ class nepalinumber:
|
|
|
197
211
|
Checks if nepalinumber is not equal to another object
|
|
198
212
|
|
|
199
213
|
:param other: The other number/object which is to be checked for
|
|
200
|
-
equality
|
|
214
|
+
equality against nepalinumber
|
|
201
215
|
:return: True if not equal else False
|
|
202
216
|
"""
|
|
203
217
|
if isinstance(other, nepalinumber):
|
|
@@ -349,7 +363,7 @@ class nepalinumber:
|
|
|
349
363
|
the nepalinumber object
|
|
350
364
|
|
|
351
365
|
:param other: The other number/object that is to get
|
|
352
|
-
|
|
366
|
+
divided by the value in the nepalinumber object
|
|
353
367
|
:raises TypeError: Raised when nepalinumber object is
|
|
354
368
|
used to divide unsupported data types
|
|
355
369
|
:return: Returns the quotient number as a nepalinumber
|
|
@@ -388,7 +402,7 @@ class nepalinumber:
|
|
|
388
402
|
before the nepalinumber object
|
|
389
403
|
|
|
390
404
|
:param other: The other number/object that is to get
|
|
391
|
-
|
|
405
|
+
divided by the value in the nepalinumber object
|
|
392
406
|
:raises TypeError: Raised when nepalinumber object is
|
|
393
407
|
used to divide unsupported data types
|
|
394
408
|
:return: Returns the quotient number as a nepalinumber
|
nepali/number/_number.py
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
|
|
3
|
-
from .utils import
|
|
4
|
-
add_comma,
|
|
5
|
-
add_comma_english,
|
|
6
|
-
english_to_nepali,
|
|
7
|
-
nepali_to_english,
|
|
8
|
-
)
|
|
3
|
+
from .utils import add_comma, add_comma_english, english_to_nepali, nepali_to_english
|
|
9
4
|
|
|
10
5
|
|
|
11
6
|
# Backward compatibility support for legacy NepaliNumber
|
nepali/number/utils.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
NP_NUMBERS = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"]
|
|
5
4
|
NP_NUMBERS_SET = set(NP_NUMBERS)
|
|
6
5
|
|
|
@@ -39,7 +38,7 @@ def add_comma_english(number: Any) -> str:
|
|
|
39
38
|
Adds comma in english style
|
|
40
39
|
Eg. 123456789 => 123,456,789
|
|
41
40
|
"""
|
|
42
|
-
return "{
|
|
41
|
+
return f"{int(number):,}"
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
def add_comma(number: Any, convert=False) -> str:
|
nepali/phone_number.py
CHANGED
|
@@ -2,10 +2,9 @@ import re
|
|
|
2
2
|
from enum import Enum
|
|
3
3
|
from typing import Union
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
_mobile_number_re = re.compile(r"^(?:\+977|977)?(?:-)?(?:98|97|96)[0-9]{8}$")
|
|
5
|
+
_mobile_number_re = re.compile(r"^(?:\+977|977)?(?:-)?(?:98|97|96)\d{8}$")
|
|
7
6
|
_landline_number_re = re.compile(
|
|
8
|
-
r"^(?:\+977|977)?(?:-)?(?:0)?(?:[01][1-9]|2[13-9]|[3-9]
|
|
7
|
+
r"^(?:\+977|977)?(?:-)?(?:0)?(?:[01][1-9]|2[13-9]|[3-9]\d)\d{6,7}$"
|
|
9
8
|
)
|
|
10
9
|
|
|
11
10
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module contains django templatetags for nepali date and time.
|
|
3
|
+
"""
|
|
1
4
|
import datetime
|
|
5
|
+
import warnings
|
|
2
6
|
from typing import Optional, Union
|
|
3
7
|
|
|
4
8
|
from django import template
|
|
@@ -11,6 +15,11 @@ from nepali.exceptions import InvalidNepaliDateTimeObjectException
|
|
|
11
15
|
from nepali.utils import to_nepalidatetime
|
|
12
16
|
|
|
13
17
|
_DEFAULT_DATE_FORMAT = "%B %d, %Y, %A"
|
|
18
|
+
DEPRECIATION_WARNING_MESSAGE = (
|
|
19
|
+
"The templatetag 'nepalidatetime' has been depreciated "
|
|
20
|
+
"and will be removed in the future release. "
|
|
21
|
+
"Please use `django-nepali` package."
|
|
22
|
+
)
|
|
14
23
|
_datetime = Union[datetime.date, datetime.datetime, _nepalidate, _nepalidatetime]
|
|
15
24
|
register = template.Library()
|
|
16
25
|
|
|
@@ -32,6 +41,10 @@ def nepalidate(
|
|
|
32
41
|
:param format: Output format, defaults to "%B %d, %Y, %A"
|
|
33
42
|
:returns: Nepali datetime format in 'en-US' locale
|
|
34
43
|
"""
|
|
44
|
+
warnings.warn(
|
|
45
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
46
|
+
category=DeprecationWarning,
|
|
47
|
+
)
|
|
35
48
|
return nepalidate_en(datetime_obj, format=format)
|
|
36
49
|
|
|
37
50
|
|
|
@@ -52,6 +65,10 @@ def nepalidate_en(
|
|
|
52
65
|
:param format: Output format, defaults to "%B %d, %Y, %A"
|
|
53
66
|
:returns: Nepali datetime format in 'en-US' locale
|
|
54
67
|
"""
|
|
68
|
+
warnings.warn(
|
|
69
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
70
|
+
category=DeprecationWarning,
|
|
71
|
+
)
|
|
55
72
|
try:
|
|
56
73
|
nepali_datetime_obj = to_nepalidatetime(datetime_obj)
|
|
57
74
|
return nepali_datetime_obj.strftime_en(format)
|
|
@@ -76,6 +93,10 @@ def nepalidate_ne(
|
|
|
76
93
|
:param format: Output format, defaults to "%B %d, %Y, %A"
|
|
77
94
|
:returns: Nepali datetime format in 'ne' locale
|
|
78
95
|
"""
|
|
96
|
+
warnings.warn(
|
|
97
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
98
|
+
category=DeprecationWarning,
|
|
99
|
+
)
|
|
79
100
|
try:
|
|
80
101
|
nepali_datetime_obj = to_nepalidatetime(datetime_obj)
|
|
81
102
|
return nepali_datetime_obj.strftime_ne(format)
|
|
@@ -103,6 +124,10 @@ def nepalihumanize(
|
|
|
103
124
|
:param format: Output format if threshold exceeded, optional
|
|
104
125
|
:returns: Datetime object in human readable form
|
|
105
126
|
"""
|
|
127
|
+
warnings.warn(
|
|
128
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
129
|
+
category=DeprecationWarning,
|
|
130
|
+
)
|
|
106
131
|
try:
|
|
107
132
|
nepali_datetime_obj = to_nepalidatetime(datetime_obj)
|
|
108
133
|
return humanize(nepali_datetime_obj, threshold=threshold, format=format)
|
|
@@ -125,6 +150,10 @@ def nepalinow(format: str = _DEFAULT_DATE_FORMAT) -> str:
|
|
|
125
150
|
:param format: Output format, defaults to "%B %d, %Y, %A"
|
|
126
151
|
:returns: Current nepali datetime
|
|
127
152
|
"""
|
|
153
|
+
warnings.warn(
|
|
154
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
155
|
+
category=DeprecationWarning,
|
|
156
|
+
)
|
|
128
157
|
return nepalinow_en(format)
|
|
129
158
|
|
|
130
159
|
|
|
@@ -143,6 +172,10 @@ def nepalinow_en(format: str = _DEFAULT_DATE_FORMAT) -> str:
|
|
|
143
172
|
:param format: Output format, defaults to "%B %d, %Y, %A"
|
|
144
173
|
:returns: Current nepali datetime
|
|
145
174
|
"""
|
|
175
|
+
warnings.warn(
|
|
176
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
177
|
+
category=DeprecationWarning,
|
|
178
|
+
)
|
|
146
179
|
return to_nepalidatetime(timezone.now()).strftime(format)
|
|
147
180
|
|
|
148
181
|
|
|
@@ -161,4 +194,8 @@ def nepalinow_ne(format: str = _DEFAULT_DATE_FORMAT) -> str:
|
|
|
161
194
|
:param format: Output format, defaults to "%B %d, %Y, %A"
|
|
162
195
|
:returns: Current nepali datetime
|
|
163
196
|
"""
|
|
197
|
+
warnings.warn(
|
|
198
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
199
|
+
category=DeprecationWarning,
|
|
200
|
+
)
|
|
164
201
|
return to_nepalidatetime(timezone.now()).strftime_ne(format)
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module contains django templatetags for nepali number.
|
|
3
|
+
"""
|
|
4
|
+
import warnings
|
|
1
5
|
from typing import Any
|
|
2
6
|
|
|
3
7
|
from django import template
|
|
@@ -11,6 +15,12 @@ from nepali.number import (
|
|
|
11
15
|
|
|
12
16
|
register = template.Library()
|
|
13
17
|
|
|
18
|
+
DEPRECIATION_WARNING_MESSAGE = (
|
|
19
|
+
"The templatetag 'nepalinumber' has been depreciated "
|
|
20
|
+
"and will be removed in the future release. "
|
|
21
|
+
"Please use `django-nepali` package."
|
|
22
|
+
)
|
|
23
|
+
|
|
14
24
|
|
|
15
25
|
@register.filter(name="nepalinumber")
|
|
16
26
|
def nepalinumber(value: Any) -> str:
|
|
@@ -25,6 +35,10 @@ def nepalinumber(value: Any) -> str:
|
|
|
25
35
|
:param value: Number to be converted
|
|
26
36
|
:returns: Nepali output of given number
|
|
27
37
|
"""
|
|
38
|
+
warnings.warn(
|
|
39
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
40
|
+
category=DeprecationWarning,
|
|
41
|
+
)
|
|
28
42
|
return english_to_nepali(value)
|
|
29
43
|
|
|
30
44
|
|
|
@@ -42,6 +56,10 @@ def nepalinumber_with_comma(value: Any) -> str:
|
|
|
42
56
|
:param value: Number to be converted and commas added
|
|
43
57
|
:returns: Nepali output of given number with commas
|
|
44
58
|
"""
|
|
59
|
+
warnings.warn(
|
|
60
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
61
|
+
category=DeprecationWarning,
|
|
62
|
+
)
|
|
45
63
|
return convert_and_add_comma(value)
|
|
46
64
|
|
|
47
65
|
|
|
@@ -58,6 +76,10 @@ def nepali_comma(value: Any) -> str:
|
|
|
58
76
|
:param value: Number to be added with commas
|
|
59
77
|
:returns: Output of given number with commas
|
|
60
78
|
"""
|
|
79
|
+
warnings.warn(
|
|
80
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
81
|
+
category=DeprecationWarning,
|
|
82
|
+
)
|
|
61
83
|
return add_comma(value)
|
|
62
84
|
|
|
63
85
|
|
|
@@ -74,4 +96,8 @@ def english_comma(value: Any) -> str:
|
|
|
74
96
|
:param value: Number to be added with commas
|
|
75
97
|
:returns: Output of given number with commas
|
|
76
98
|
"""
|
|
99
|
+
warnings.warn(
|
|
100
|
+
message=DEPRECIATION_WARNING_MESSAGE,
|
|
101
|
+
category=DeprecationWarning,
|
|
102
|
+
)
|
|
77
103
|
return add_comma_english(value)
|
nepali/tests/test_datetime.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import unittest
|
|
3
3
|
|
|
4
|
-
from nepali.datetime import nepalidate,
|
|
5
|
-
from nepali.datetime.utils import
|
|
4
|
+
from nepali.datetime import nepalidate, nepalidatetime, nepalitime
|
|
5
|
+
from nepali.datetime.utils import to_nepalidate, to_nepalidatetime
|
|
6
6
|
from nepali.exceptions import InvalidNepaliDateTimeObjectException
|
|
7
7
|
from nepali.timezone import NepaliTimeZone
|
|
8
8
|
|
|
@@ -250,9 +250,7 @@ class TestNepaliDateTime(unittest.TestCase):
|
|
|
250
250
|
self.assertEqual(
|
|
251
251
|
nepalidatetime_obj1,
|
|
252
252
|
nepalidatetime_obj2,
|
|
253
|
-
msg="{} and {} are not equal"
|
|
254
|
-
nepalidatetime_obj1, nepalidatetime_obj2
|
|
255
|
-
),
|
|
253
|
+
msg=f"{nepalidatetime_obj1} and {nepalidatetime_obj2} are not equal",
|
|
256
254
|
)
|
|
257
255
|
|
|
258
256
|
|
nepali/tests/test_humanize.py
CHANGED
|
@@ -2,11 +2,10 @@ import datetime
|
|
|
2
2
|
import unittest
|
|
3
3
|
from unittest.mock import patch
|
|
4
4
|
|
|
5
|
-
from nepali.datetime import
|
|
5
|
+
from nepali.datetime import HumanizeDateTime, nepalidate, nepalidatetime, nepalihumanize
|
|
6
6
|
from nepali.exceptions import InvalidNepaliDateTimeObjectException
|
|
7
7
|
from nepali.timezone import NepaliTimeZone
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
REF_TIME = datetime.datetime(2015, 1, 1, 10, 15, tzinfo=NepaliTimeZone())
|
|
11
10
|
|
|
12
11
|
|
nepali/tests/test_locations.py
CHANGED
|
@@ -2,17 +2,17 @@ import unittest
|
|
|
2
2
|
|
|
3
3
|
from nepali import locations
|
|
4
4
|
from nepali.locations.models import (
|
|
5
|
+
District,
|
|
5
6
|
Location,
|
|
7
|
+
Municipality,
|
|
6
8
|
MunicipalityType,
|
|
7
9
|
Province,
|
|
8
|
-
District,
|
|
9
|
-
Municipality,
|
|
10
10
|
)
|
|
11
11
|
from nepali.locations.utils import (
|
|
12
12
|
_filter_location,
|
|
13
|
-
get_province,
|
|
14
13
|
get_district,
|
|
15
14
|
get_municipality,
|
|
15
|
+
get_province,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
|
nepali/tests/test_number.py
CHANGED
|
@@ -7,7 +7,7 @@ import sys
|
|
|
7
7
|
import unittest
|
|
8
8
|
|
|
9
9
|
from nepali import number
|
|
10
|
-
from nepali.number import
|
|
10
|
+
from nepali.number import NepaliNumber, nepalinumber
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class TestNumber(unittest.TestCase):
|
|
@@ -170,7 +170,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
170
170
|
self.nepalinumber_integer_10 + (-15.5), self.nepalinumber_negative_float_5_5
|
|
171
171
|
)
|
|
172
172
|
|
|
173
|
-
def
|
|
173
|
+
def test_nepalinumber_integer_is_addable_to_positive_nepali_number_integer(self):
|
|
174
174
|
self.assertEqual(
|
|
175
175
|
self.nepalinumber_integer_10 + self.nepalinumber_integer_10,
|
|
176
176
|
self.nepalinumber_integer_20,
|
|
@@ -280,7 +280,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
280
280
|
self.nepalinumber_negative_integer_10 + 15.5, self.nepalinumber_float_5_5
|
|
281
281
|
)
|
|
282
282
|
|
|
283
|
-
def
|
|
283
|
+
def test_negative_nepalinumber_integer_is_addable_to_positive_nepali_number_integer(
|
|
284
284
|
self,
|
|
285
285
|
):
|
|
286
286
|
self.assertEqual(
|
|
@@ -365,7 +365,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
365
365
|
self.nepalinumber_float_10_1 + (-15.6), self.nepalinumber_negative_float_5_5
|
|
366
366
|
)
|
|
367
367
|
|
|
368
|
-
def
|
|
368
|
+
def test_nepalinumber_float_is_addable_to_positive_nepali_number_integer(self):
|
|
369
369
|
self.assertEqual(
|
|
370
370
|
self.nepalinumber_float_10_1 + self.nepalinumber_integer_10,
|
|
371
371
|
self.nepalinumber_float_20_1,
|
|
@@ -443,7 +443,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
443
443
|
self.nepalinumber_negative_float_10_1 + 15.6, self.nepalinumber_float_5_5
|
|
444
444
|
)
|
|
445
445
|
|
|
446
|
-
def
|
|
446
|
+
def test_negative_nepalinumber_float_is_addable_to_positive_nepali_number_integer(
|
|
447
447
|
self,
|
|
448
448
|
):
|
|
449
449
|
self.assertEqual(
|
|
@@ -542,7 +542,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
542
542
|
self.nepalinumber_integer_10 - (-5.5), self.nepalinumber_float_15_5
|
|
543
543
|
)
|
|
544
544
|
|
|
545
|
-
def
|
|
545
|
+
def test_nepalinumber_integer_is_subtractable_by_positive_nepali_number_integer(
|
|
546
546
|
self,
|
|
547
547
|
):
|
|
548
548
|
self.assertEqual(
|
|
@@ -629,7 +629,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
629
629
|
self.nepalinumber_negative_integer_10 - (-15.5), self.nepalinumber_float_5_5
|
|
630
630
|
)
|
|
631
631
|
|
|
632
|
-
def
|
|
632
|
+
def test_negative_nepalinumber_integer_is_subtractable_by_positive_nepali_number_integer(
|
|
633
633
|
self,
|
|
634
634
|
):
|
|
635
635
|
self.assertEqual(
|
|
@@ -700,7 +700,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
700
700
|
self.nepalinumber_float_10_1 - (-5.4), self.nepalinumber_float_15_5
|
|
701
701
|
)
|
|
702
702
|
|
|
703
|
-
def
|
|
703
|
+
def test_nepalinumber_float_is_subtractable_by_positive_nepali_number_integer(self):
|
|
704
704
|
self.assertEqual(
|
|
705
705
|
self.nepalinumber_float_10_1 - self.nepalinumber_integer_10,
|
|
706
706
|
self.nepalinumber_float_0_0_9,
|
|
@@ -771,7 +771,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
771
771
|
self.nepalinumber_negative_float_10_1 - (-15.6), self.nepalinumber_float_5_5
|
|
772
772
|
)
|
|
773
773
|
|
|
774
|
-
def
|
|
774
|
+
def test_negative_nepalinumber_float_is_subtractable_by_positive_nepali_number_integer(
|
|
775
775
|
self,
|
|
776
776
|
):
|
|
777
777
|
self.assertEqual(
|
|
@@ -872,7 +872,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
872
872
|
self.nepalinumber_integer_10 * (-1.5), self.nepalinumber_negative_integer_15
|
|
873
873
|
)
|
|
874
874
|
|
|
875
|
-
def
|
|
875
|
+
def test_nepalinumber_integer_is_multiplicable_to_positive_nepali_number_integer(
|
|
876
876
|
self,
|
|
877
877
|
):
|
|
878
878
|
self.assertEqual(
|
|
@@ -955,7 +955,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
955
955
|
self.nepalinumber_integer_15,
|
|
956
956
|
)
|
|
957
957
|
|
|
958
|
-
def
|
|
958
|
+
def test_negative_nepalinumber_integer_is_multiplicable_to_positive_nepali_number_integer(
|
|
959
959
|
self,
|
|
960
960
|
):
|
|
961
961
|
self.assertEqual(
|
|
@@ -1008,7 +1008,9 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1008
1008
|
self.nepalinumber_float_4_5 * (-2.2), self.nepalinumber_negative_float_9_9
|
|
1009
1009
|
)
|
|
1010
1010
|
|
|
1011
|
-
def
|
|
1011
|
+
def test_nepalinumber_float_is_multiplicable_to_positive_nepali_number_integer(
|
|
1012
|
+
self,
|
|
1013
|
+
):
|
|
1012
1014
|
self.assertEqual(
|
|
1013
1015
|
self.nepalinumber_float_10_1 * self.nepalinumber_integer_2,
|
|
1014
1016
|
self.nepalinumber_float_20_2,
|
|
@@ -1059,7 +1061,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1059
1061
|
self.nepalinumber_float_5_25,
|
|
1060
1062
|
)
|
|
1061
1063
|
|
|
1062
|
-
def
|
|
1064
|
+
def test_negative_nepalinumber_float_is_multiplicable_to_positive_nepali_number_integer(
|
|
1063
1065
|
self,
|
|
1064
1066
|
):
|
|
1065
1067
|
self.assertEqual(
|
|
@@ -1075,7 +1077,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1075
1077
|
self.nepalinumber_negative_float_2_25,
|
|
1076
1078
|
)
|
|
1077
1079
|
|
|
1078
|
-
def
|
|
1080
|
+
def test_negative_nepalinumber_float_is_multiplicable_to_negative_nepali_number_integer(
|
|
1079
1081
|
self,
|
|
1080
1082
|
):
|
|
1081
1083
|
self.assertEqual(
|
|
@@ -1180,7 +1182,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1180
1182
|
self.nepalinumber_integer_10 / (-2.5), self.nepalinumber_negative_integer_4
|
|
1181
1183
|
)
|
|
1182
1184
|
|
|
1183
|
-
def
|
|
1185
|
+
def test_nepalinumber_integer_is_divisible_by_positive_nepali_number_integer(self):
|
|
1184
1186
|
self.assertEqual(
|
|
1185
1187
|
self.nepalinumber_integer_20 / self.nepalinumber_integer_10,
|
|
1186
1188
|
self.nepalinumber_integer_2,
|
|
@@ -1276,7 +1278,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1276
1278
|
self.nepalinumber_negative_integer_10 / -2.5, self.nepalinumber_integer_4
|
|
1277
1279
|
)
|
|
1278
1280
|
|
|
1279
|
-
def
|
|
1281
|
+
def test_negative_nepalinumber_integer_is_divisible_by_positive_nepali_number_integer(
|
|
1280
1282
|
self,
|
|
1281
1283
|
):
|
|
1282
1284
|
self.assertEqual(
|
|
@@ -1338,7 +1340,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1338
1340
|
self.nepalinumber_float_20_2 / (-10.1), self.nepalinumber_negative_integer_2
|
|
1339
1341
|
)
|
|
1340
1342
|
|
|
1341
|
-
def
|
|
1343
|
+
def test_nepalinumber_float_is_divisible_by_positive_nepali_number_integer(self):
|
|
1342
1344
|
self.assertEqual(
|
|
1343
1345
|
self.nepalinumber_float_20_2 / self.nepalinumber_integer_2,
|
|
1344
1346
|
self.nepalinumber_float_10_1,
|
|
@@ -1387,7 +1389,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1387
1389
|
self.nepalinumber_integer_2,
|
|
1388
1390
|
)
|
|
1389
1391
|
|
|
1390
|
-
def
|
|
1392
|
+
def test_negative_nepalinumber_float_is_divisible_by_positive_nepali_number_integer(
|
|
1391
1393
|
self,
|
|
1392
1394
|
):
|
|
1393
1395
|
self.assertEqual(
|
|
@@ -1470,7 +1472,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1470
1472
|
|
|
1471
1473
|
self.assertEqual(str(ze.exception), "division by zero")
|
|
1472
1474
|
|
|
1473
|
-
# floor
|
|
1475
|
+
# floor division
|
|
1474
1476
|
# nepalinumber positive integer division tests
|
|
1475
1477
|
def test_nepalinumber_integer_is_floor_divisible_by_positive_integer(self):
|
|
1476
1478
|
self.assertEqual(
|
|
@@ -1492,7 +1494,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1492
1494
|
self.nepalinumber_integer_10 // (-2.5), self.nepalinumber_negative_integer_4
|
|
1493
1495
|
)
|
|
1494
1496
|
|
|
1495
|
-
def
|
|
1497
|
+
def test_nepalinumber_integer_is_floor_divisible_by_positive_nepali_number_integer(
|
|
1496
1498
|
self,
|
|
1497
1499
|
):
|
|
1498
1500
|
self.assertEqual(
|
|
@@ -1600,7 +1602,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1600
1602
|
self.nepalinumber_negative_integer_10 // -2.5, self.nepalinumber_integer_4
|
|
1601
1603
|
)
|
|
1602
1604
|
|
|
1603
|
-
def
|
|
1605
|
+
def test_negative_nepalinumber_integer_is_floor_divisible_by_positive_nepali_number_integer(
|
|
1604
1606
|
self,
|
|
1605
1607
|
):
|
|
1606
1608
|
self.assertEqual(
|
|
@@ -1665,7 +1667,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1665
1667
|
self.nepalinumber_negative_integer_2,
|
|
1666
1668
|
)
|
|
1667
1669
|
|
|
1668
|
-
def
|
|
1670
|
+
def test_nepalinumber_float_is_floor_divisible_by_positive_nepali_number_integer(
|
|
1669
1671
|
self,
|
|
1670
1672
|
):
|
|
1671
1673
|
self.assertEqual(
|
|
@@ -1722,7 +1724,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1722
1724
|
self.nepalinumber_integer_2,
|
|
1723
1725
|
)
|
|
1724
1726
|
|
|
1725
|
-
def
|
|
1727
|
+
def test_negative_nepalinumber_float_is_floor_divisible_by_positive_nepali_number_integer(
|
|
1726
1728
|
self,
|
|
1727
1729
|
):
|
|
1728
1730
|
self.assertEqual(
|
|
@@ -1896,7 +1898,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1896
1898
|
self.nepalinumber_negative_integer_10,
|
|
1897
1899
|
)
|
|
1898
1900
|
|
|
1899
|
-
def
|
|
1901
|
+
def test_nepalinumber_integer_can_be_modulo_divided_by_negative_nepalinumber_float(
|
|
1900
1902
|
self,
|
|
1901
1903
|
):
|
|
1902
1904
|
self.assertEqual(
|
|
@@ -1945,7 +1947,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
1945
1947
|
self.nepalinumber_integer_10,
|
|
1946
1948
|
)
|
|
1947
1949
|
|
|
1948
|
-
def
|
|
1950
|
+
def test_negative_nepalinumber_float_can_be_modulo_divided_by_positive_nepalinumber_integer(
|
|
1949
1951
|
self,
|
|
1950
1952
|
):
|
|
1951
1953
|
self.assertEqual(
|
|
@@ -2000,7 +2002,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2000
2002
|
self.nepalinumber_negative_integer_10,
|
|
2001
2003
|
)
|
|
2002
2004
|
|
|
2003
|
-
def
|
|
2005
|
+
def test_negative_nepalinumber_integer_can_be_modulo_divided_by_negative_nepalinumber_float(
|
|
2004
2006
|
self,
|
|
2005
2007
|
):
|
|
2006
2008
|
self.assertEqual(
|
|
@@ -2048,7 +2050,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2048
2050
|
self.nepalinumber_negative_float_5_5,
|
|
2049
2051
|
)
|
|
2050
2052
|
|
|
2051
|
-
def
|
|
2053
|
+
def test_negative_nepalinumber_float_can_be_modulo_divided_by_negative_nepalinumber_integer(
|
|
2052
2054
|
self,
|
|
2053
2055
|
):
|
|
2054
2056
|
self.assertEqual(
|
|
@@ -2096,7 +2098,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2096
2098
|
self.nepalinumber_negative_float_15_5,
|
|
2097
2099
|
)
|
|
2098
2100
|
|
|
2099
|
-
def
|
|
2101
|
+
def test_nepalinumber_float_can_be_modulo_divided_by_negative_nepalinumber_float(
|
|
2100
2102
|
self,
|
|
2101
2103
|
):
|
|
2102
2104
|
self.assertEqual(
|
|
@@ -2148,7 +2150,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2148
2150
|
self.nepalinumber_integer_2,
|
|
2149
2151
|
)
|
|
2150
2152
|
|
|
2151
|
-
def
|
|
2153
|
+
def test_negative_nepalinumber_float_can_be_modulo_divided_by_negative_nepalinumber_integer_2(
|
|
2152
2154
|
self,
|
|
2153
2155
|
):
|
|
2154
2156
|
self.assertEqual(
|
|
@@ -2290,7 +2292,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2290
2292
|
),
|
|
2291
2293
|
)
|
|
2292
2294
|
|
|
2293
|
-
# divmod positive nepalinumber integer as
|
|
2295
|
+
# divmod positive nepalinumber integer as divisor tests
|
|
2294
2296
|
def test_positive_integer_can_be_divmod_with_positive_nepalinumber_integer(self):
|
|
2295
2297
|
self.assertEqual(
|
|
2296
2298
|
divmod(10, self.nepalinumber_integer_2),
|
|
@@ -2397,7 +2399,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2397
2399
|
),
|
|
2398
2400
|
)
|
|
2399
2401
|
|
|
2400
|
-
# divmod positive nepalinumber float as
|
|
2402
|
+
# divmod positive nepalinumber float as divisor tests
|
|
2401
2403
|
def test_positive_integer_can_be_divmod_with_positive_nepalinumber_float(self):
|
|
2402
2404
|
self.assertEqual(
|
|
2403
2405
|
divmod(10, self.nepalinumber_float_2_5),
|
|
@@ -2485,7 +2487,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2485
2487
|
(self.nepalinumber_integer_1, self.nepalinumber_negative_float_4_5),
|
|
2486
2488
|
)
|
|
2487
2489
|
|
|
2488
|
-
# divmod negative nepalinumber integer as
|
|
2490
|
+
# divmod negative nepalinumber integer as divisor tests
|
|
2489
2491
|
def test_positive_integer_can_be_divmod_with_negative_nepalinumber_integer(self):
|
|
2490
2492
|
self.assertEqual(
|
|
2491
2493
|
divmod(10, self.nepalinumber_negative_integer_2),
|
|
@@ -2557,7 +2559,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
|
|
|
2557
2559
|
(self.nepalinumber_integer_1, self.nepalinumber_negative_integer_2),
|
|
2558
2560
|
)
|
|
2559
2561
|
|
|
2560
|
-
# divmod negative nepalinumber float as
|
|
2562
|
+
# divmod negative nepalinumber float as divisor tests
|
|
2561
2563
|
def test_positive_integer_can_be_divmod_with_negative_nepalinumber_float(self):
|
|
2562
2564
|
self.assertEqual(
|
|
2563
2565
|
divmod(10, self.nepalinumber_negative_float_2_5),
|