Skip to content

Commit

Permalink
Add tests for percentage() function Refs #1602
Browse files Browse the repository at this point in the history
  • Loading branch information
man4oni authored and atodorov committed Aug 10, 2020
1 parent 9616d67 commit e980a6f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tcms/core/tests/test_report_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
import unittest
from tcms.core.templatetags.report_tags import percentage


class TestReportTagPercentage(unittest.TestCase):

def test_percentage_calculation(self):

with self.assertRaises(ValueError):
percentage('five', 'ten')
self.assertEqual('0.0%', percentage(0, 2.0))
self.assertEqual('0%', percentage(2.0, 0))
self.assertEqual(percentage(1, 1), '100.0%')
self.assertEqual(percentage(1, 3), '33.3%')
self.assertEqual(percentage(4.5, 4), '112.5%')

0 comments on commit e980a6f

Please sign in to comment.