Exemple #1
0
    def test_it_errors_for_missing_deprecations(self):
        recorder = testing.Recorder()
        regret = Deprecator(emit=recorder.emit)

        deprecated = regret.callable(version="1.2.3")(calculate)

        with self.assertRaises(testing.ExpectedDifferentDeprecations):
            with recorder.expect_deprecations(
                emitted.Deprecation(kind=emitted.Callable(object=deprecated)),
                emitted.Deprecation(kind=emitted.Callable(object=deprecated)),
            ):
                deprecated()
Exemple #2
0
    def test_it_sees_emitted_deprecations(self):
        recorder = testing.Recorder()
        regret = Deprecator(emit=recorder.emit)

        deprecated = regret.callable(version="1.2.3")(calculate)

        with recorder.expect_deprecations(
            emitted.Deprecation(kind=emitted.Callable(object=deprecated)),
            emitted.Deprecation(kind=emitted.Callable(object=deprecated)),
        ):
            deprecated()
            deprecated()
Exemple #3
0
 def _emit_deprecation(self, extra_stacklevel=0, **kwargs):
     self._emit(
         deprecation=emitted.Deprecation(name_of=self._name_of, **kwargs),
         extra_stacklevel=extra_stacklevel,
     )