Lines Matching refs:self

47     def test_ignored_deprecations_are_silent(self):
53 self.assertEqual(len(messages), 0, messages)
55 def test_import_module(self):
57 self.assertRaises(unittest.SkipTest,
60 def test_import_fresh_module(self):
63 def test_get_attribute(self):
64 self.assertEqual(support.get_attribute(self, "test_get_attribute"),
65 self.test_get_attribute)
66 self.assertRaises(unittest.SkipTest, support.get_attribute, self, "foo")
69 def test_get_original_stdout(self):
70 self.assertEqual(support.get_original_stdout(), sys.stdout)
72 def test_unload(self):
74 self.assertIn("sched", sys.modules)
76 self.assertNotIn("sched", sys.modules)
78 def test_unlink(self):
82 self.assertFalse(os.path.exists(TESTFN))
85 def test_rmtree(self):
91 self.assertFalse(os.path.exists(dirpath))
100 self.assertFalse(os.path.exists(dirpath))
107 self.assertFalse(os.path.exists(dirpath))
109 def test_forget(self):
117 self.assertIn(TESTFN, sys.modules)
120 self.assertNotIn(TESTFN, sys.modules)
127 def test_HOST(self):
132 def test_find_unused_port(self):
138 def test_bind_port(self):
146 def test_temp_dir(self):
153 self.assertFalse(os.path.isdir(path))
155 self.assertEqual(temp_path, path)
156 self.assertTrue(os.path.isdir(path))
157 self.assertFalse(os.path.isdir(path))
161 def test_temp_dir__path_none(self):
164 self.assertTrue(os.path.isdir(temp_path))
165 self.assertFalse(os.path.isdir(temp_path))
167 def test_temp_dir__existing_dir__quiet_default(self):
176 self.assertTrue(os.path.isdir(path))
177 self.assertRaises(FileExistsError, call_temp_dir, path)
179 self.assertTrue(os.path.isdir(path))
183 def test_temp_dir__existing_dir__quiet_true(self):
191 self.assertEqual(path, temp_path)
194 self.assertTrue(os.path.isdir(path))
198 self.assertEqual(len(warnings), 1, warnings)
200 self.assertTrue(warn.startswith(f'tests may fail, unable to create '
205 def test_temp_dir__forked_child(self):
231 def test_change_cwd(self):
236 self.assertEqual(new_cwd, temp_path)
237 self.assertEqual(os.getcwd(), new_cwd)
239 self.assertEqual(os.getcwd(), original_cwd)
241 def test_change_cwd__non_existent_dir(self):
251 self.assertRaises(FileNotFoundError, call_change_cwd,
254 self.assertEqual(os.getcwd(), original_cwd)
256 def test_change_cwd__non_existent_dir__quiet_true(self):
264 self.assertEqual(new_cwd, original_cwd)
265 self.assertEqual(os.getcwd(), new_cwd)
268 self.assertEqual(len(warnings), 1, warnings)
270 self.assertTrue(warn.startswith(f'tests may fail, unable to change '
277 def test_change_cwd__chdir_warning(self):
285 self.assertEqual(len(messages), 1, messages)
287 self.assertTrue(msg.startswith(f'tests may fail, unable to change '
294 def test_temp_cwd(self):
297 self.assertEqual(os.path.basename(os.getcwd()), TESTFN)
298 self.assertFalse(os.path.exists(TESTFN))
299 self.assertEqual(os.getcwd(), here)
302 def test_temp_cwd__name_none(self):
306 self.assertNotEqual(new_cwd, original_cwd)
307 self.assertTrue(os.path.isdir(new_cwd))
308 self.assertEqual(os.getcwd(), new_cwd)
309 self.assertEqual(os.getcwd(), original_cwd)
311 def test_sortdict(self):
312 self.assertEqual(support.sortdict({3:3, 2:2, 1:1}), "{1: 1, 2: 2, 3: 3}")
314 def test_make_bad_fd(self):
316 with self.assertRaises(OSError) as cm:
318 self.assertEqual(cm.exception.errno, errno.EBADF)
320 def test_check_syntax_error(self):
321 support.check_syntax_error(self, "def class", lineno=1, offset=5)
322 with self.assertRaises(AssertionError):
323 support.check_syntax_error(self, "x=1")
325 def test_CleanImport(self):
330 def test_DirsOnSysPath(self):
332 self.assertIn("foo", sys.path)
333 self.assertIn("bar", sys.path)
334 self.assertNotIn("foo", sys.path)
335 self.assertNotIn("bar", sys.path)
337 def test_captured_stdout(self):
340 self.assertEqual(stdout.getvalue(), "hello\n")
342 def test_captured_stderr(self):
345 self.assertEqual(stderr.getvalue(), "hello\n")
347 def test_captured_stdin(self):
353 self.assertEqual(captured, "hello")
355 def test_gc_collect(self):
358 def test_python_is_optimized(self):
359 self.assertIsInstance(support.python_is_optimized(), bool)
361 def test_swap_attr(self):
367 self.assertEqual(obj.x, 5)
368 self.assertEqual(x, 1)
369 self.assertEqual(obj.x, 1)
371 self.assertEqual(obj.y, 5)
372 self.assertIsNone(y)
373 self.assertFalse(hasattr(obj, 'y'))
376 self.assertFalse(hasattr(obj, 'y'))
378 def test_swap_item(self):
381 self.assertEqual(D["x"], 5)
382 self.assertEqual(x, 1)
383 self.assertEqual(D["x"], 1)
385 self.assertEqual(D["y"], 5)
386 self.assertIsNone(y)
387 self.assertNotIn("y", D)
390 self.assertNotIn("y", D)
404 def test_detect_api_mismatch(self):
405 missing_items = support.detect_api_mismatch(self.RefClass,
406 self.OtherClass)
407 self.assertEqual({'attribute1'}, missing_items)
409 missing_items = support.detect_api_mismatch(self.OtherClass,
410 self.RefClass)
411 self.assertEqual({'attribute3', '__magic_2__'}, missing_items)
413 def test_detect_api_mismatch__ignore(self):
417 self.RefClass, self.OtherClass, ignore=ignore)
418 self.assertEqual(set(), missing_items)
421 self.OtherClass, self.RefClass, ignore=ignore)
422 self.assertEqual(set(), missing_items)
424 def test_check__all__(self):
427 support.check__all__(self,
440 support.check__all__(self,
449 self.assertRaises(AssertionError, support.check__all__, self, unittest)
454 def test_reap_children(self):
474 self.fail("timeout")
488 self.assertIn(msg, stderr.getvalue())
489 self.assertTrue(support.environment_altered)
498 def check_options(self, args, func, expected=None):
510 self.assertEqual(proc.stdout.rstrip(), repr(expected))
511 self.assertEqual(proc.returncode, 0)
513 def test_args_from_interpreter_flags(self):
542 with self.subTest(opts=opts):
543 self.check_options(opts, 'args_from_interpreter_flags')
545 self.check_options(['-I', '-E', '-s', '-P'],
549 def test_optim_args_from_interpreter_flags(self):
558 with self.subTest(opts=opts):
559 self.check_options(opts, 'optim_args_from_interpreter_flags')
561 def test_match_test(self):
563 def __init__(self, test_id):
564 self.test_id = test_id
566 def id(self):
567 return self.test_id
576 self.assertTrue(support.match_test(test_access))
577 self.assertTrue(support.match_test(test_chdir))
581 self.assertTrue(support.match_test(test_access))
582 self.assertTrue(support.match_test(test_chdir))
586 self.assertTrue(support.match_test(test_access))
587 self.assertFalse(support.match_test(test_chdir))
591 self.assertTrue(support.match_test(test_access))
592 self.assertTrue(support.match_test(test_chdir))
596 self.assertTrue(support.match_test(test_access))
597 self.assertTrue(support.match_test(test_chdir))
601 self.assertFalse(support.match_test(test_access))
603 self.assertTrue(support.match_test(test_access))
607 self.assertTrue(support.match_test(test_access))
608 self.assertTrue(support.match_test(test_chdir))
612 self.assertTrue(support.match_test(test_access))
613 self.assertTrue(support.match_test(test_chdir))
616 self.assertTrue(support.match_test(test_access))
617 self.assertFalse(support.match_test(test_chdir))
623 self.assertTrue(support.match_test(test_access))
624 self.assertTrue(support.match_test(test_chdir))
628 self.assertTrue(support.match_test(test_access))
629 self.assertTrue(support.match_test(test_chdir))
633 self.assertFalse(support.match_test(test_access))
634 self.assertTrue(support.match_test(test_chdir))
638 self.assertFalse(support.match_test(test_access))
639 self.assertFalse(support.match_test(test_chdir))
643 self.assertFalse(support.match_test(test_access))
644 self.assertFalse(support.match_test(test_chdir))
648 self.assertTrue(support.match_test(test_access))
650 self.assertFalse(support.match_test(test_access))
654 self.assertFalse(support.match_test(test_access))
655 self.assertFalse(support.match_test(test_chdir))
659 self.assertFalse(support.match_test(test_access))
660 self.assertFalse(support.match_test(test_chdir))
663 self.assertFalse(support.match_test(test_access))
664 self.assertTrue(support.match_test(test_chdir))
668 def test_fd_count(self):
680 self.assertEqual(more - start, 1)
682 def check_print_warning(self, msg, expected):
686 self.assertEqual(stderr.getvalue(), expected)
688 def test_print_warning(self):
689 self.check_print_warning("msg",
691 self.check_print_warning("a\nb",
694 def test_has_strftime_extensions(self):
696 self.assertFalse(support.has_strftime_extensions)
698 self.assertTrue(support.has_strftime_extensions)