mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	| @@ -393,27 +393,27 @@ def internal_link(link, text) -> str: | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| def add(x, y, *args, **kwargs): | ||||
| def add(x: float, y: float, *args, **kwargs) -> float: | ||||
|     """Add two numbers together.""" | ||||
|     return x + y | ||||
|     return float(x) + float(y) | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| def subtract(x, y): | ||||
| def subtract(x: float, y: float) -> float: | ||||
|     """Subtract one number from another.""" | ||||
|     return x - y | ||||
|     return float(x) - float(y) | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| def multiply(x, y): | ||||
| def multiply(x: float, y: float) -> float: | ||||
|     """Multiply two numbers together.""" | ||||
|     return x * y | ||||
|     return float(x) * float(y) | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| def divide(x, y): | ||||
| def divide(x: float, y: float) -> float: | ||||
|     """Divide one number by another.""" | ||||
|     return x / y | ||||
|     return float(x) / float(y) | ||||
|  | ||||
|  | ||||
| @register.simple_tag | ||||
|   | ||||
| @@ -197,10 +197,15 @@ class ReportTagTest(PartImageTestMixin, InvenTreeTestCase): | ||||
|     def test_maths_tags(self): | ||||
|         """Simple tests for mathematical operator tags.""" | ||||
|         self.assertEqual(report_tags.add(1, 2), 3) | ||||
|         self.assertEqual(report_tags.add('-33', '33'), 0) | ||||
|         self.assertEqual(report_tags.subtract(10, 4.2), 5.8) | ||||
|         self.assertEqual(report_tags.multiply(2.3, 4), 9.2) | ||||
|         self.assertEqual(report_tags.multiply('-2', 4), -8.0) | ||||
|         self.assertEqual(report_tags.divide(100, 5), 20) | ||||
|  | ||||
|         with self.assertRaises(ZeroDivisionError): | ||||
|             report_tags.divide(100, 0) | ||||
|  | ||||
|     def test_number_tags(self): | ||||
|         """Simple tests for number formatting tags.""" | ||||
|         fn = report_tags.format_number | ||||
|   | ||||
		Reference in New Issue
	
	Block a user