summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_webbrowser.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-08 15:15:54 (GMT)
committerGitHub <noreply@github.com>2017-03-08 15:15:54 (GMT)
commita7cba27aea138311117e2ab1d91584efcfeac4ec (patch)
treec2e6b9e0802057f71b43e17fe27a53e50c12a283 /Lib/test/test_webbrowser.py
parent8606e9524a7a4065042f7f228dc57eb74f88e4d3 (diff)
downloadcpython-a7cba27aea138311117e2ab1d91584efcfeac4ec.zip
cpython-a7cba27aea138311117e2ab1d91584efcfeac4ec.tar.gz
cpython-a7cba27aea138311117e2ab1d91584efcfeac4ec.tar.bz2
bpo-29645: Speed up importing the webbrowser module. (#484)
Diffstat (limited to 'Lib/test/test_webbrowser.py')
-rw-r--r--Lib/test/test_webbrowser.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_webbrowser.py b/Lib/test/test_webbrowser.py
index 622c1cb..0820b91 100644
--- a/Lib/test/test_webbrowser.py
+++ b/Lib/test/test_webbrowser.py
@@ -266,5 +266,30 @@ class BrowserRegistrationTest(unittest.TestCase):
self._check_registration(preferred=True)
+class ImportTest(unittest.TestCase):
+ def test_register(self):
+ webbrowser = support.import_fresh_module('webbrowser')
+ self.assertIsNone(webbrowser._tryorder)
+ self.assertFalse(webbrowser._browsers)
+
+ class ExampleBrowser:
+ pass
+ webbrowser.register('Example1', ExampleBrowser)
+ self.assertTrue(webbrowser._tryorder)
+ self.assertEqual(webbrowser._tryorder[-1], 'Example1')
+ self.assertTrue(webbrowser._browsers)
+ self.assertIn('example1', webbrowser._browsers)
+ self.assertEqual(webbrowser._browsers['example1'], [ExampleBrowser, None])
+
+ def test_get(self):
+ webbrowser = support.import_fresh_module('webbrowser')
+ self.assertIsNone(webbrowser._tryorder)
+ self.assertFalse(webbrowser._browsers)
+
+ with self.assertRaises(webbrowser.Error):
+ webbrowser.get('fakebrowser')
+ self.assertIsNotNone(webbrowser._tryorder)
+
+
if __name__=='__main__':
unittest.main()