~pythonregexp2.7/python/issue2636-01+09-02

« back to all changes in this revision

Viewing changes to Lib/test/test_file.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 00:16:16 UTC
  • mfrom: (39022.1.34 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922001616-p1wdip9lfp0zl5cu
Merged in changes from the Atomic Grouping / Possessive Qualifiers branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
503
503
        self._test_close_open_io(io_func)
504
504
 
505
505
 
 
506
class StdoutTests(unittest.TestCase):
 
507
 
 
508
    def test_move_stdout_on_write(self):
 
509
        # Issue 3242: sys.stdout can be replaced (and freed) during a
 
510
        # print statement; prevent a segfault in this case
 
511
        save_stdout = sys.stdout
 
512
 
 
513
        class File:
 
514
            def write(self, data):
 
515
                if '\n' in data:
 
516
                    sys.stdout = save_stdout
 
517
 
 
518
        try:
 
519
            sys.stdout = File()
 
520
            print "some text"
 
521
        finally:
 
522
            sys.stdout = save_stdout
 
523
 
506
524
 
507
525
def test_main():
508
526
    # Historically, these tests have been sloppy about removing TESTFN.
509
527
    # So get rid of it no matter what.
510
528
    try:
511
529
        run_unittest(AutoFileTests, OtherFileTests, FileSubclassTests,
512
 
            FileThreadingTests)
 
530
            FileThreadingTests, StdoutTests)
513
531
    finally:
514
532
        if os.path.exists(TESTFN):
515
533
            os.unlink(TESTFN)