forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show equivalent pytest command (#6363)
This is just a quick change to help users trouble-shoot problems with pytest. When there is a failure, we print out the command they can run at the shell to duplicate the error.
- Loading branch information
1 parent
c02d504
commit 796169c
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import shlex | ||
import unittest | ||
|
||
from testing_tools.adapter.util import shlex_unsplit | ||
|
||
|
||
class ShlexUnsplitTests(unittest.TestCase): | ||
|
||
def test_no_args(self): | ||
argv = [] | ||
joined = shlex_unsplit(argv) | ||
|
||
self.assertEqual(joined, '') | ||
self.assertEqual(shlex.split(joined), argv) | ||
|
||
def test_one_arg(self): | ||
argv = ['spam'] | ||
joined = shlex_unsplit(argv) | ||
|
||
self.assertEqual(joined, 'spam') | ||
self.assertEqual(shlex.split(joined), argv) | ||
|
||
def test_multiple_args(self): | ||
argv = [ | ||
'-x', 'X', | ||
'-xyz', | ||
'spam', | ||
'eggs', | ||
] | ||
joined = shlex_unsplit(argv) | ||
|
||
self.assertEqual(joined, '-x X -xyz spam eggs') | ||
self.assertEqual(shlex.split(joined), argv) | ||
|
||
def test_whitespace(self): | ||
argv = [ | ||
'-x', 'X Y Z', | ||
'spam spam\tspam', | ||
'eggs', | ||
] | ||
joined = shlex_unsplit(argv) | ||
|
||
self.assertEqual(joined, "-x 'X Y Z' 'spam spam\tspam' eggs") | ||
self.assertEqual(shlex.split(joined), argv) | ||
|
||
def test_quotation_marks(self): | ||
argv = [ | ||
'-x', "'<quoted>'", | ||
'spam"spam"spam', | ||
"ham'ham'ham", | ||
'eggs', | ||
] | ||
joined = shlex_unsplit(argv) | ||
|
||
self.assertEqual(joined, "-x ''\"'\"'<quoted>'\"'\"'' 'spam\"spam\"spam' 'ham'\"'\"'ham'\"'\"'ham' eggs") | ||
self.assertEqual(shlex.split(joined), argv) |