mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
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.
This commit is contained in:
parent
25059d30c3
commit
78f0dd3397
1 changed files with 6 additions and 6 deletions
|
|
@ -23,8 +23,7 @@ from email import Errors
|
||||||
from email import Encoders
|
from email import Encoders
|
||||||
from email import Iterators
|
from email import Iterators
|
||||||
|
|
||||||
import test_email
|
from test_support import findfile, __file__ as test_support_file
|
||||||
from test_support import findfile
|
|
||||||
|
|
||||||
|
|
||||||
NL = '\n'
|
NL = '\n'
|
||||||
|
|
@ -34,7 +33,7 @@ SPACE = ' '
|
||||||
|
|
||||||
|
|
||||||
def openfile(filename):
|
def openfile(filename):
|
||||||
path = os.path.join(os.path.dirname(test_email.__file__), 'data', filename)
|
path = os.path.join(os.path.dirname(test_support_file), 'data', filename)
|
||||||
return open(path)
|
return open(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1041,8 +1040,9 @@ def suite():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def test_main():
|
||||||
unittest.main(defaultTest='suite')
|
|
||||||
else:
|
|
||||||
from test_support import run_suite
|
from test_support import run_suite
|
||||||
run_suite(suite())
|
run_suite(suite())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
test_main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue