@@ -57,6 +57,14 @@ def _test(self, meth, *, args=[URL], kw={}, options, arguments):
5757 popen_args .pop (popen_args .index (option ))
5858 self .assertEqual (popen_args , arguments )
5959
60+ def test_reject_dash_prefixes (self ):
61+ browser = self .browser_class (name = CMD_NAME )
62+ with self .assertRaisesRegex (
63+ ValueError ,
64+ r"^Invalid URL \(leading dash disallowed\): '--key=val http.*'$"
65+ ):
66+ browser .open (f"--key=val { URL } " )
67+
6068
6169class GenericBrowserCommandTest (CommandTestMixin , unittest .TestCase ):
6270
@@ -67,11 +75,6 @@ def test_open(self):
6775 options = [],
6876 arguments = [URL ])
6977
70- def test_reject_dash_prefixes (self ):
71- browser = self .browser_class (name = CMD_NAME )
72- with self .assertRaises (ValueError ):
73- browser .open (f"--key=val { URL } " )
74-
7578
7679class BackgroundBrowserCommandTest (CommandTestMixin , unittest .TestCase ):
7780
@@ -326,6 +329,7 @@ def close(self):
326329@unittest .skipUnless (sys .platform == "darwin" , "macOS specific test" )
327330@requires_subprocess ()
328331class MacOSXOSAScriptTest (unittest .TestCase ):
332+ maxDiff = None
329333
330334 def setUp (self ):
331335 # Ensure that 'BROWSER' is not set to 'open' or something else.
@@ -376,6 +380,13 @@ def test_explicit_browser(self):
376380 self .assertIn ('tell application "safari"' , script )
377381 self .assertIn ('open location "https://python.org"' , script )
378382
383+ def test_reject_dash_prefixes (self ):
384+ with self .assertRaisesRegex (
385+ ValueError ,
386+ r"^Invalid URL \(leading dash disallowed\): '--key=val http.*'$"
387+ ):
388+ self .browser .open (f"--key=val { URL } " )
389+
379390
380391class BrowserRegistrationTest (unittest .TestCase ):
381392
0 commit comments