diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/talos/tests/test_utils.py | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/talos/tests/test_utils.py')
-rw-r--r-- | testing/talos/tests/test_utils.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/testing/talos/tests/test_utils.py b/testing/talos/tests/test_utils.py new file mode 100644 index 000000000..0157234f5 --- /dev/null +++ b/testing/talos/tests/test_utils.py @@ -0,0 +1,40 @@ +from talos import utils +import unittest +import os + + +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) |