gecko-dev/testing/talos/tests/test_utils.py
Ionut Goldan f3028165fe Bug 1396217 - resolve py2 and py3 lint errors r=jmaher
MozReview-Commit-ID: LG332HzJKcw

--HG--
extra : rebase_source : b82da0cceac18f310cadf945578464c2fb4704c4
2017-09-08 11:27:26 +03:00

44 lines
1.3 KiB
Python

from __future__ import absolute_import
import os
import unittest
from talos import utils
class TestTimer(unittest.TestCase):
def test_timer(self):
timer = utils.Timer()
timer._start_time -= 3 # remove three seconds for the test
self.assertEquals(timer.elapsed(), '00:00:03')
class TestRestoreEnv(unittest.TestCase):
def test_basic(self):
env_var = 'THIS_IS_A_ENV_VAR_NOT_USED'
self.assertNotIn(env_var, os.environ)
with utils.restore_environment_vars():
os.environ[env_var] = '1'
self.assertNotIn(env_var, os.environ)
class TestInterpolate(unittest.TestCase):
def test_interpolate_talos_is_always_defines(self):
self.assertEquals(utils.interpolate('${talos}'), utils.here)
def test_interpolate_custom_placeholders(self):
self.assertEquals(utils.interpolate('${talos} ${foo} abc', foo='bar', unused=1),
utils.here + ' bar abc')
class TestParsePref(unittest.TestCase):
def test_parse_string(self):
self.assertEquals(utils.parse_pref('abc'), 'abc')
def test_parse_int(self):
self.assertEquals(utils.parse_pref('12'), 12)
def test_parse_bool(self):
self.assertEquals(utils.parse_pref('true'), True)
self.assertEquals(utils.parse_pref('false'), False)