~ubuntu-branches/ubuntu/quantal/python3.3/quantal-security

« back to all changes in this revision

Viewing changes to Lib/test/test_importlib/extension/test_case_sensitivity.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-08-13 11:05:00 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20120813110500-9dn5gbekscobbqpz
Tags: 3.3.0~b2-1
* Python 3.3.0 beta2 release.
* Fix removal of the _tkinter and dbm extensions for multiarch builds.
  Closes: #684461.
* Use _sysconfigdata.py in distutils to initialize distutils.
  Closes: #682475.
* Fix symlink for static libpython. Closes: #684608.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import imp
 
2
import sys
 
3
from test import support
 
4
import unittest
 
5
from importlib import _bootstrap
 
6
from .. import util
 
7
from . import util as ext_util
 
8
 
 
9
 
 
10
@util.case_insensitive_tests
 
11
class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
 
12
 
 
13
    def find_module(self):
 
14
        good_name = ext_util.NAME
 
15
        bad_name = good_name.upper()
 
16
        assert good_name != bad_name
 
17
        finder = _bootstrap.FileFinder(ext_util.PATH,
 
18
                                        (_bootstrap.ExtensionFileLoader,
 
19
                                         _bootstrap.EXTENSION_SUFFIXES))
 
20
        return finder.find_module(bad_name)
 
21
 
 
22
    def test_case_sensitive(self):
 
23
        with support.EnvironmentVarGuard() as env:
 
24
            env.unset('PYTHONCASEOK')
 
25
            if b'PYTHONCASEOK' in _bootstrap._os.environ:
 
26
                self.skipTest('os.environ changes not reflected in '
 
27
                              '_os.environ')
 
28
            loader = self.find_module()
 
29
            self.assertIsNone(loader)
 
30
 
 
31
    def test_case_insensitivity(self):
 
32
        with support.EnvironmentVarGuard() as env:
 
33
            env.set('PYTHONCASEOK', '1')
 
34
            if b'PYTHONCASEOK' not in _bootstrap._os.environ:
 
35
                self.skipTest('os.environ changes not reflected in '
 
36
                              '_os.environ')
 
37
            loader = self.find_module()
 
38
            self.assertTrue(hasattr(loader, 'load_module'))
 
39
 
 
40
 
 
41
 
 
42
 
 
43
def test_main():
 
44
    if ext_util.FILENAME is None:
 
45
        return
 
46
    support.run_unittest(ExtensionModuleCaseSensitivityTest)
 
47
 
 
48
 
 
49
if __name__ == '__main__':
 
50
    test_main()