コード例 #1
0
ファイル: test_pelita_player.py プロジェクト: ASPP/pelita
 def test_load_team(self):
     for path, result in self.load_team_cases:
         print(path, result)
         if result is not None:
             with pytest.raises(result):
                 load_team(path)
         else:
             load_team(path)
コード例 #2
0
ファイル: test_pelita_player.py プロジェクト: ASPP/pelita
 def test_load_team(self):
     for path, result in self.load_team_cases:
         print(path, result)
         if result is not None:
             with pytest.raises(result):
                 load_team(path)
         else:
             load_team(path)
コード例 #3
0
ファイル: test_pelita_player.py プロジェクト: ASPP/pelita
    def test_simple_module_import_allowed_names(self):
        names = ["a", "a a", "0" * 25]
        for idx, name in enumerate(names):
            modules_before = list(sys.modules.keys())
            with tempfile.TemporaryDirectory() as d:
                module = Path(d) / ("teamy_%i" % idx)
                module.mkdir()
                initfile = module / "__init__.py"
                with initfile.open(mode='w') as f:
                    f.write(SIMPLE_MODULE % (name,))

                spec = str(module)
                load_team(spec)
コード例 #4
0
ファイル: test_pelita_player.py プロジェクト: ASPP/pelita
    def test_simple_module_import_allowed_names(self):
        names = ["a", "a a", "0" * 25]
        for idx, name in enumerate(names):
            modules_before = list(sys.modules.keys())
            with tempfile.TemporaryDirectory() as d:
                module = Path(d) / ("teamy_%i" % idx)
                module.mkdir()
                initfile = module / "__init__.py"
                with initfile.open(mode='w') as f:
                    f.write(SIMPLE_MODULE % (name,))

                spec = str(module)
                load_team(spec)
コード例 #5
0
ファイル: test_pelita_player.py プロジェクト: ASPP/pelita
    def test_simple_module_import_forbidden_names(self):
        names = ["", " ", "-", "∂", "0" * 26]
        for idx, name in enumerate(names):
            modules_before = list(sys.modules.keys())
            with tempfile.TemporaryDirectory() as d:
                module = Path(d) / ("teamx_%i" % idx)
                module.mkdir()
                initfile = module / "__init__.py"
                with initfile.open(mode='w') as f:
                    f.write(SIMPLE_MODULE % (name,))

                spec = str(module)
                with pytest.raises(ValueError):
                    load_team(spec)
コード例 #6
0
    def test_simple_module_import_forbidden_names(self):
        names = ["", " ", "-", "∂", "0" * 26]
        for idx, name in enumerate(names):
            modules_before = list(sys.modules.keys())
            with tempfile.TemporaryDirectory() as d:
                module = Path(d) / ("teamx_%i" % idx)
                module.mkdir()
                initfile = module / "__init__.py"
                with initfile.open(mode='w') as f:
                    f.write(SIMPLE_MODULE % (name, ))

                spec = str(module)
                with pytest.raises(ValueError):
                    load_team(spec)
コード例 #7
0
ファイル: test_pelita_player.py プロジェクト: ASPP/pelita
    def test_simple_module_import_forbidden_names(self):
        names = ["", " ", "-", "∂", "0" * 26]
        for idx, name in enumerate(names):
            modules_before = list(sys.modules.keys())
            with tempfile.TemporaryDirectory() as d:
                module = Path(d) / ("teamx_%i" % idx)
                module.mkdir()
                initfile = module / "__init__.py"
                with initfile.open(mode='w') as f:
                    try:
                        f.write(SIMPLE_MODULE % (name,))
                    except UnicodeEncodeError:
                        if _mswindows:
                            # Ignore UnicodeEncodeErrors on Windows for this test
                            # It is too complicate to debug this
                            continue
                        else:
                            raise

                spec = str(module)
                with pytest.raises(ValueError):
                    load_team(spec)