##// END OF EJS Templates
Merge pull request #13448 from naterush/master...
Matthias Bussonnier -
r27450:34d45e08 merge
parent child Browse files
Show More
@@ -406,13 +406,18 b' class TestShellGlob(unittest.TestCase):'
406 self.check_match(patterns, matches)
406 self.check_match(patterns, matches)
407
407
408
408
409 # TODO : pytest.mark.parametrise once nose is gone.
409 @pytest.mark.parametrize(
410 def test_unescape_glob():
410 "globstr, unescaped_globstr",
411 assert path.unescape_glob(r"\*\[\!\]\?") == "*[!]?"
411 [
412 assert path.unescape_glob(r"\\*") == r"\*"
412 (r"\*\[\!\]\?", "*[!]?"),
413 assert path.unescape_glob(r"\\\*") == r"\*"
413 (r"\\*", r"\*"),
414 assert path.unescape_glob(r"\\a") == r"\a"
414 (r"\\\*", r"\*"),
415 assert path.unescape_glob(r"\a") == r"\a"
415 (r"\\a", r"\a"),
416 (r"\a", r"\a"),
417 ],
418 )
419 def test_unescape_glob(globstr, unescaped_globstr):
420 assert path.unescape_glob(globstr) == unescaped_globstr
416
421
417
422
418 @onlyif_unicode_paths
423 @onlyif_unicode_paths
@@ -1,4 +1,3 b''
1 # encoding: utf-8
2 """
1 """
3 Tests for platutils.py
2 Tests for platutils.py
4 """
3 """
@@ -56,35 +55,37 b' def test_find_cmd_fail():'
56 pytest.raises(FindCmdError, find_cmd, "asdfasdf")
55 pytest.raises(FindCmdError, find_cmd, "asdfasdf")
57
56
58
57
59 # TODO: move to pytest.mark.parametrize once nose gone
60 @dec.skip_win32
58 @dec.skip_win32
61 def test_arg_split():
59 @pytest.mark.parametrize(
60 "argstr, argv",
61 [
62 ("hi", ["hi"]),
63 ("hello there", ["hello", "there"]),
64 # \u01ce == \N{LATIN SMALL LETTER A WITH CARON}
65 # Do not use \N because the tests crash with syntax error in
66 # some cases, for example windows python2.6.
67 ("h\u01cello", ["h\u01cello"]),
68 ('something "with quotes"', ["something", '"with quotes"']),
69 ],
70 )
71 def test_arg_split(argstr, argv):
62 """Ensure that argument lines are correctly split like in a shell."""
72 """Ensure that argument lines are correctly split like in a shell."""
63 tests = [['hi', ['hi']],
73 assert arg_split(argstr) == argv
64 [u'hi', [u'hi']],
74
65 ['hello there', ['hello', 'there']],
75
66 # \u01ce == \N{LATIN SMALL LETTER A WITH CARON}
67 # Do not use \N because the tests crash with syntax error in
68 # some cases, for example windows python2.6.
69 [u'h\u01cello', [u'h\u01cello']],
70 ['something "with quotes"', ['something', '"with quotes"']],
71 ]
72 for argstr, argv in tests:
73 assert arg_split(argstr) == argv
74
75
76 # TODO: move to pytest.mark.parametrize once nose gone
77 @dec.skip_if_not_win32
76 @dec.skip_if_not_win32
78 def test_arg_split_win32():
77 @pytest.mark.parametrize(
78 "argstr,argv",
79 [
80 ("hi", ["hi"]),
81 ("hello there", ["hello", "there"]),
82 ("h\u01cello", ["h\u01cello"]),
83 ('something "with quotes"', ["something", "with quotes"]),
84 ],
85 )
86 def test_arg_split_win32(argstr, argv):
79 """Ensure that argument lines are correctly split like in a shell."""
87 """Ensure that argument lines are correctly split like in a shell."""
80 tests = [['hi', ['hi']],
88 assert arg_split(argstr) == argv
81 [u'hi', [u'hi']],
82 ['hello there', ['hello', 'there']],
83 [u'h\u01cello', [u'h\u01cello']],
84 ['something "with quotes"', ['something', 'with quotes']],
85 ]
86 for argstr, argv in tests:
87 assert arg_split(argstr) == argv
88
89
89
90
90 class SubProcessTestCase(tt.TempFileMixin):
91 class SubProcessTestCase(tt.TempFileMixin):
@@ -98,7 +99,7 b' class SubProcessTestCase(tt.TempFileMixin):'
98 self.mktmp('\n'.join(lines))
99 self.mktmp('\n'.join(lines))
99
100
100 def test_system(self):
101 def test_system(self):
101 status = system('%s "%s"' % (python, self.fname))
102 status = system(f'{python} "{self.fname}"')
102 self.assertEqual(status, 0)
103 self.assertEqual(status, 0)
103
104
104 def test_system_quotes(self):
105 def test_system_quotes(self):
@@ -145,11 +146,11 b' class SubProcessTestCase(tt.TempFileMixin):'
145
146
146 status = self.assert_interrupts(command)
147 status = self.assert_interrupts(command)
147 self.assertNotEqual(
148 self.assertNotEqual(
148 status, 0, "The process wasn't interrupted. Status: %s" % (status,)
149 status, 0, f"The process wasn't interrupted. Status: {status}"
149 )
150 )
150
151
151 def test_getoutput(self):
152 def test_getoutput(self):
152 out = getoutput('%s "%s"' % (python, self.fname))
153 out = getoutput(f'{python} "{self.fname}"')
153 # we can't rely on the order the line buffered streams are flushed
154 # we can't rely on the order the line buffered streams are flushed
154 try:
155 try:
155 self.assertEqual(out, 'on stderron stdout')
156 self.assertEqual(out, 'on stderron stdout')
@@ -169,7 +170,7 b' class SubProcessTestCase(tt.TempFileMixin):'
169 self.assertEqual(out.strip(), '1')
170 self.assertEqual(out.strip(), '1')
170
171
171 def test_getoutput_error(self):
172 def test_getoutput_error(self):
172 out, err = getoutputerror('%s "%s"' % (python, self.fname))
173 out, err = getoutputerror(f'{python} "{self.fname}"')
173 self.assertEqual(out, 'on stdout')
174 self.assertEqual(out, 'on stdout')
174 self.assertEqual(err, 'on stderr')
175 self.assertEqual(err, 'on stderr')
175
176
@@ -179,7 +180,7 b' class SubProcessTestCase(tt.TempFileMixin):'
179 self.assertEqual(out, '')
180 self.assertEqual(out, '')
180 self.assertEqual(err, '')
181 self.assertEqual(err, '')
181 self.assertEqual(code, 1)
182 self.assertEqual(code, 1)
182 out, err, code = get_output_error_code('%s "%s"' % (python, self.fname))
183 out, err, code = get_output_error_code(f'{python} "{self.fname}"')
183 self.assertEqual(out, 'on stdout')
184 self.assertEqual(out, 'on stdout')
184 self.assertEqual(err, 'on stderr')
185 self.assertEqual(err, 'on stderr')
185 self.assertEqual(code, 0)
186 self.assertEqual(code, 0)
@@ -80,24 +80,22 b' def test_columnize_random():'
80 )
80 )
81
81
82
82
83 # TODO: pytest mark.parametrize once nose removed.
83 @pytest.mark.parametrize("row_first", [True, False])
84 def test_columnize_medium():
84 def test_columnize_medium(row_first):
85 """Test with inputs than shouldn't be wider than 80"""
85 """Test with inputs than shouldn't be wider than 80"""
86 size = 40
86 size = 40
87 items = [l*size for l in 'abc']
87 items = [l*size for l in 'abc']
88 for row_first in [True, False]:
88 out = text.columnize(items, row_first=row_first, displaywidth=80)
89 out = text.columnize(items, row_first=row_first, displaywidth=80)
89 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
90 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
91
90
92
91
93 # TODO: pytest mark.parametrize once nose removed.
92 @pytest.mark.parametrize("row_first", [True, False])
94 def test_columnize_long():
93 def test_columnize_long(row_first):
95 """Test columnize with inputs longer than the display window"""
94 """Test columnize with inputs longer than the display window"""
96 size = 11
95 size = 11
97 items = [l*size for l in 'abc']
96 items = [l*size for l in 'abc']
98 for row_first in [True, False]:
97 out = text.columnize(items, row_first=row_first, displaywidth=size - 1)
99 out = text.columnize(items, row_first=row_first, displaywidth=size - 1)
98 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
100 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
101
99
102
100
103 def eval_formatter_check(f):
101 def eval_formatter_check(f):
General Comments 0
You need to be logged in to leave comments. Login now