Пример #1
0
 def test_pip_install_with_import_error_and_windows_os(self):
     os_name_swap = self.swap(common, 'OS_NAME', 'Windows')
     import pip
     try:
         sys.modules['pip'] = None
         with os_name_swap, self.print_swap, self.swap_check_call:
             with self.assertRaisesRegexp(
                     Exception, 'Error importing pip: No module named pip'):
                 install_backend_python_libs.pip_install(
                     'package==version', 'path')
     finally:
         sys.modules['pip'] = pip
     self.assertTrue(
         'https://github.com/oppia/oppia/wiki/Installing-Oppia-%28'
         'Windows%29' in self.print_arr)
    def test_pip_install_with_import_error_and_linux_os(self):
        os_name_swap = self.swap(common, 'OS_NAME', 'Linux')

        import pip
        try:
            sys.modules['pip'] = None
            with os_name_swap, self.print_swap, self.swap_check_call:
                with self.assertRaisesRegexp(
                        ImportError,
                        'Error importing pip: import of pip halted; '
                        'None in sys.modules'):
                    install_backend_python_libs.pip_install(
                        'package==version', 'path')
        finally:
            sys.modules['pip'] = pip
        self.assertTrue(
            'https://github.com/oppia/oppia/wiki/Installing-Oppia-%28Linux'
            '%29' in self.print_arr)
Пример #3
0
 def test_pip_install_exception_handling(self):
     with self.assertRaisesRegexp(Exception,
                                  'Error installing package') as context:
         install_backend_python_libs.pip_install('package==version', 'path')
     self.assertTrue('Error installing package' in context.exception)
Пример #4
0
 def test_pip_install_with_user_prefix_error(self):
     with self.swap_Popen_error, self.swap_check_call:
         install_backend_python_libs.pip_install('pkg==ver', 'path')
Пример #5
0
 def test_pip_install_without_import_error(self):
     with self.swap_Popen:
         install_backend_python_libs.pip_install('package==version', 'path')
 def test_pip_install_exception_handling(self):
     with self.assertRaisesRegex(
         Exception, 'Error installing package'
     ):
         install_backend_python_libs.pip_install('package==version', 'path')