~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_win32utils.py

Merge cleanup into first-try

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
Win32RegistryFeature = _RequiredModuleFeature('_winreg')
55
55
CtypesFeature = _RequiredModuleFeature('ctypes')
56
56
Win32comShellFeature = _RequiredModuleFeature('win32com.shell')
 
57
Win32ApiFeature = _RequiredModuleFeature('win32api') 
57
58
 
58
59
 
59
60
# Tests
189
190
        # typical windows users should have wordpad in the system
190
191
        # but there is problem: its path has the format REG_EXPAND_SZ
191
192
        # so naive attempt to get the path is not working
 
193
        self.requireFeature(Win32ApiFeature)
192
194
        for a in ('wordpad', 'wordpad.exe'):
193
195
            p = get_app_path(a)
194
196
            d, b = os.path.split(p)
276
278
 
277
279
class Test_CommandLineToArgv(tests.TestCaseInTempDir):
278
280
 
279
 
    def assertCommandLine(self, expected, line, single_quotes_allowed=False):
 
281
    def assertCommandLine(self, expected, line, argv=None,
 
282
            single_quotes_allowed=False):
280
283
        # Strictly speaking we should respect parameter order versus glob
281
284
        # expansions, but it's not really worth the effort here
282
 
        argv = win32utils._command_line_to_argv(line,
 
285
        if argv is None:
 
286
            argv = [line]
 
287
        argv = win32utils._command_line_to_argv(line, argv,
283
288
                single_quotes_allowed=single_quotes_allowed)
284
289
        self.assertEqual(expected, sorted(argv))
285
290
 
313
318
 
314
319
    def test_single_quote_support(self):
315
320
        self.assertCommandLine(["add", "let's-do-it.txt"],
316
 
            "add let's-do-it.txt")
317
 
        self.assertCommandLine(["add", "lets do it.txt"],
318
 
            "add 'lets do it.txt'", single_quotes_allowed=True)
 
321
            "add let's-do-it.txt",
 
322
            ["add", "let's-do-it.txt"])
 
323
        self.expectFailure("Using single quotes breaks trimming from argv",
 
324
            self.assertCommandLine, ["add", "lets do it.txt"],
 
325
            "add 'lets do it.txt'", ["add", "'lets", "do", "it.txt'"],
 
326
            single_quotes_allowed=True)
319
327
 
320
328
    def test_case_insensitive_globs(self):
321
329
        self.requireFeature(tests.CaseInsCasePresFilenameFeature)
326
334
        self.requireFeature(backslashdir_feature)
327
335
        self.build_tree(['a/', 'a/b.c', 'a/c.c', 'a/c.h'])
328
336
        self.assertCommandLine([u'a/b.c'], 'a\\b*')
 
337
 
 
338
    def test_with_pdb(self):
 
339
        """Check stripping Python arguments before bzr script per lp:587868"""
 
340
        self.assertCommandLine([u"rocks"], "-m pdb rocks", ["rocks"])
 
341
        self.build_tree(['d/', 'd/f1', 'd/f2'])
 
342
        self.assertCommandLine([u"rm", u"x*"], "-m pdb rm x*", ["rm", u"x*"])
 
343
        self.assertCommandLine([u"add", u"d/f1", u"d/f2"], "-m pdb add d/*",
 
344
            ["add", u"d/*"])