コード例 #1
0
    def test_bad_class(self):
        """This returns a class which doesn't inherient from fitter """

        mock_entry_badclass = mock.create_autospec(EntryPoint)
        mock_entry_badclass.name = "BadClass"
        mock_entry_badclass.load = self.returnbadclass

        with pytest.warns(AstropyUserWarning, match=r".*BadClass.*"):
            populate_entry_points([mock_entry_badclass])
コード例 #2
0
    def test_bad_func(self):
        """This returns a function which fails the type check"""

        mock_entry_badfunc = mock.create_autospec(EntryPoint)
        mock_entry_badfunc.name = "BadFunc"
        mock_entry_badfunc.load = self.returnbadfunc

        with pytest.warns(AstropyUserWarning, match=r".*Class.*"):
            populate_entry_points([mock_entry_badfunc])
コード例 #3
0
    def test_import_error(self):
        """This raises an import error on load to test that it is handled correctly"""

        mock_entry_importerror = mock.create_autospec(EntryPoint)
        mock_entry_importerror.name = "IErr"
        mock_entry_importerror.load = self.raiseimporterror

        with pytest.warns(AstropyUserWarning, match=r".*ImportError.*"):
            populate_entry_points([mock_entry_importerror])
コード例 #4
0
ファイル: test_fitters.py プロジェクト: weaverba137/astropy
 def test_bad_class(self):
     """This returns a class which doesn't inherient from fitter """
     with warnings.catch_warnings():
         warnings.filterwarnings('error')
         try:
             mock_entry_badclass = mock.create_autospec(EntryPoint)
             mock_entry_badclass.name = "BadClass"
             mock_entry_badclass.load = self.returnbadclass
             populate_entry_points([mock_entry_badclass])
         except AstropyUserWarning as w:
             if 'modeling.Fitter' in w.args[0]:  # any error for this case should have this in it.
                 pass
             else:
                 raise w
         else:
             raise self.exception_not_thrown
コード例 #5
0
ファイル: test_fitters.py プロジェクト: weaverba137/astropy
 def test_bad_func(self):
     """This returns a function which fails the type check"""
     with warnings.catch_warnings():
         warnings.filterwarnings('error')
         try:
             mock_entry_badfunc = mock.create_autospec(EntryPoint)
             mock_entry_badfunc.name = "BadFunc"
             mock_entry_badfunc.load = self.returnbadfunc
             populate_entry_points([mock_entry_badfunc])
         except AstropyUserWarning as w:
             if "Class" in w.args[0]:  # any error for this case should have this in it.
                 pass
             else:
                 raise w
         else:
             raise self.exception_not_thrown
コード例 #6
0
ファイル: test_fitters.py プロジェクト: weaverba137/astropy
 def test_import_error(self):
     """This raises an import error on load to test that it is handled correctly"""
     with warnings.catch_warnings():
         warnings.filterwarnings('error')
         try:
             mock_entry_importerror = mock.create_autospec(EntryPoint)
             mock_entry_importerror.name = "IErr"
             mock_entry_importerror.load = self.raiseimporterror
             populate_entry_points([mock_entry_importerror])
         except AstropyUserWarning as w:
             if "ImportError" in w.args[0]:  # any error for this case should have this in it.
                 pass
             else:
                 raise w
         else:
             raise self.exception_not_thrown
コード例 #7
0
ファイル: test_fitters.py プロジェクト: MaxNoe/astropy
 def test_bad_class(self):
     """This returns a class which doesn't inherient from fitter """
     with warnings.catch_warnings():
         warnings.filterwarnings('error')
         try:
             mock_entry_badclass = mock.create_autospec(EntryPoint)
             mock_entry_badclass.name = "BadClass"
             mock_entry_badclass.load = self.returnbadclass
             populate_entry_points([mock_entry_badclass])
         except AstropyUserWarning as w:
             if 'modeling.Fitter' in w.args[0]:  # any error for this case should have this in it.
                 pass
             else:
                 raise w
         else:
             raise self.exception_not_thrown
コード例 #8
0
ファイル: test_fitters.py プロジェクト: MaxNoe/astropy
 def test_bad_func(self):
     """This returns a function which fails the type check"""
     with warnings.catch_warnings():
         warnings.filterwarnings('error')
         try:
             mock_entry_badfunc = mock.create_autospec(EntryPoint)
             mock_entry_badfunc.name = "BadFunc"
             mock_entry_badfunc.load = self.returnbadfunc
             populate_entry_points([mock_entry_badfunc])
         except AstropyUserWarning as w:
             if "Class" in w.args[0]:  # any error for this case should have this in it.
                 pass
             else:
                 raise w
         else:
             raise self.exception_not_thrown
コード例 #9
0
ファイル: test_fitters.py プロジェクト: MaxNoe/astropy
 def test_import_error(self):
     """This raises an import error on load to test that it is handled correctly"""
     with warnings.catch_warnings():
         warnings.filterwarnings('error')
         try:
             mock_entry_importerror = mock.create_autospec(EntryPoint)
             mock_entry_importerror.name = "IErr"
             mock_entry_importerror.load = self.raiseimporterror
             populate_entry_points([mock_entry_importerror])
         except AstropyUserWarning as w:
             if "ImportError" in w.args[0]:  # any error for this case should have this in it.
                 pass
             else:
                 raise w
         else:
             raise self.exception_not_thrown
コード例 #10
0
ファイル: test_fitters.py プロジェクト: weaverba137/astropy
 def test_working(self):
     """This should work fine"""
     mock_entry_working = mock.create_autospec(EntryPoint)
     mock_entry_working.name = "Working"
     mock_entry_working.load = self.successfulimport
     populate_entry_points([mock_entry_working])
コード例 #11
0
ファイル: test_fitters.py プロジェクト: MaxNoe/astropy
 def test_working(self):
     """This should work fine"""
     mock_entry_working = mock.create_autospec(EntryPoint)
     mock_entry_working.name = "Working"
     mock_entry_working.load = self.successfulimport
     populate_entry_points([mock_entry_working])