[issue15557] Tests for webbrowser module

Chris Jerdonek report at bugs.python.org
Sun Aug 12 18:30:19 CEST 2012


Chris Jerdonek added the comment:

It still seems like things could be made more DRY.  Also, the pattern of having assert_unix_browser() execute various function blocks depending on whether various arguments are not None doesn't seem as clean or scalable as it should be (e.g. if the number of assert statements were to grow).

What about defining helper methods like check_open(), check_open_new_tab(), and check_open_new(), and then having the various test_<browser>() methods call each of them as appropriate?  For example--

+        browser.open_new('http://www.example.com/')
+        args = popen.cmd_line
+        self.assertEqual(args, ['test', '-raise', '-remote',
+            'openURL(http://www.example.com/,new-window)'])

could become a call to check_open_new().  The helper methods could default to the most common string arguments so that you will only need to define and pass the string arguments when the browser uses strings that are different from the defaults.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15557>
_______________________________________


More information about the Python-bugs-list mailing list