Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Misc site tests
- Made for Jython.
- """
- from __future__ import with_statement
- import os
- import shutil
- import subprocess
- import sys
- import unittest
- from test import test_support
- ENCODING_TEST = 'utf16'
- SITECUSTOMIZE = """\
- import sys
- sys.setdefaultencoding(%r)
- """ % ENCODING_TEST
- class SiteCustomize(unittest.TestCase):
- def setUp(self):
- os.mkdir(test_support.TESTFN)
- with open(os.path.join(test_support.TESTFN, 'sitecustomize.py'),
- 'w') as fp:
- fp.write(SITECUSTOMIZE)
- def tearDown(self):
- shutil.rmtree(test_support.TESTFN)
- def test_setdefaultencoding(self):
- test = ('import sys;'
- 'print "%s|%s" % '
- '(sys.getdefaultencoding(), sys.stdin.encoding)')
- env = os.environ.copy()
- env['PYTHONPATH'] = test_support.TESTFN
- popen = subprocess.Popen([sys.executable, '-c', test],
- stdout=subprocess.PIPE,
- env=env)
- result = popen.communicate()[0].rstrip()
- self.assertEqual('%s|%s' % (ENCODING_TEST, ENCODING_TEST), result)
- def test_main():
- test_support.run_unittest(SiteCustomize)
- if __name__ == '__main__':
- test_main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement