Lines Matching refs:self
36 def __init__(self, x):
37 self.x = x
39 def __str__(self):
40 return self.x
46 def check(self, expected, args,
61 self.assertEqual(t.getvalue(), expected)
63 def test_print(self):
68 self.check(expected, args, sep=sep, end=end)
72 self.check('', args, sep=sep, end=end, file=o)
75 self.assertEqual(o.getvalue(), expected)
99 self.assertRaises(TypeError, print, '', sep=3)
100 self.assertRaises(TypeError, print, '', end=3)
101 self.assertRaises(AttributeError, print, '', file='')
103 def test_print_flush(self):
106 def __init__(self):
107 self.written = ''
108 self.flushed = 0
110 def write(self, str):
111 self.written += str
113 def flush(self):
114 self.flushed += 1
120 self.assertEqual(f.written, '123\n')
121 self.assertEqual(f.flushed, 2)
125 def write(self, str):
128 def flush(self):
130 self.assertRaises(RuntimeError, print, 1, file=noflush(), flush=True)
138 def test_normal_string(self):
140 with self.assertRaises(SyntaxError) as context:
143 self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
146 def test_string_with_soft_space(self):
148 with self.assertRaises(SyntaxError) as context:
151 self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
154 def test_string_with_excessive_whitespace(self):
156 with self.assertRaises(SyntaxError) as context:
159 self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
162 def test_string_with_leading_whitespace(self):
166 with self.assertRaises(SyntaxError) as context:
169 self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
175 def test_string_with_semicolon(self):
177 with self.assertRaises(SyntaxError) as context:
180 self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
183 def test_string_in_loop_on_same_line(self):
185 with self.assertRaises(SyntaxError) as context:
188 self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
191 def test_stream_redirection_hint_for_py2_migration(self):
193 with self.assertRaises(TypeError) as context:
195 self.assertIn('Did you mean "print(<message>, '
200 with self.assertRaises(TypeError) as context:
202 self.assertIn('Did you mean "print(<message>, '
206 with self.assertRaises(TypeError) as context:
208 self.assertNotIn('Did you mean ', str(context.exception))
211 with self.assertRaises(TypeError) as context:
213 self.assertNotIn('Did you mean', str(context.exception))
217 def __rrshift__(self, lhs):
220 self.assertEqual(print >> OverrideRRShift(), 42)