# -*- coding: utf-8 -*- from q3stats.lib import stats from q3stats.testing import BaseQ3StatsTestCase class Test_LibStats(BaseQ3StatsTestCase): def test_weapon_accuracy_gauntlet(self): result = stats.weapon_accuracy('G', {'hits': 0, 'shots': 0}) assert result == '---' def test_weapon_accuracy_no_shots(self): result = stats.weapon_accuracy('BFG', {'hits': 1, 'shots': 0}) assert result == 'NaN' def test_weapon_accuracy(self): result = stats.weapon_accuracy('BFG', {'hits': 1, 'shots': 2}) assert result == '50.00%' def test_powerup_time_no_time(self): result = stats.powerup_time(0) assert result == 'NaN' def test_powerup_time_less_than_1s(self): result = stats.powerup_time(123) assert result == '0.123' def test_powerup_time(self): result = stats.powerup_time(12345) assert result == '12.345'