[Python-checkins] CVS: python/dist/src/Lib/test test_email.py,1.22,1.23

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 07 Dec 2001 13:07:12 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv22060

Modified Files:
	test_email.py 
Log Message:
I found that when run as a script, this test suite ran its tests
twice!  Fixed this by avoiding the import of test_email, which loads
the module a second time in that situation, and fiddled the __main__
section to resemble other test suites using unittest.


Index: test_email.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** test_email.py	2001/11/27 07:12:35	1.22
--- test_email.py	2001/12/07 21:07:08	1.23
***************
*** 24,29 ****
  from email import Iterators
  
! import test_email
! from test_support import findfile
  
  
--- 24,28 ----
  from email import Iterators
  
! from test_support import findfile, __file__ as test_support_file
  
  
***************
*** 35,39 ****
  
  def openfile(filename):
!     path = os.path.join(os.path.dirname(test_email.__file__), 'data', filename)
      return open(path)
  
--- 34,38 ----
  
  def openfile(filename):
!     path = os.path.join(os.path.dirname(test_support_file), 'data', filename)
      return open(path)
  
***************
*** 1042,1048 ****
  
  
! if __name__ == '__main__':
!     unittest.main(defaultTest='suite')
! else:
      from test_support import run_suite
      run_suite(suite())
--- 1041,1048 ----
  
  
! def test_main():
      from test_support import run_suite
      run_suite(suite())
+ 
+ if __name__ == '__main__':
+     test_main()