コード例 #1
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()
コード例 #2
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()
コード例 #3
0
 def call_deprecated(*args, **kwargs):
     self._emit_deprecation(
         kind=emitted.Callable(object=call_deprecated),
         replacement=replacement,
         removal_date=removal_date,
         addendum=addendum,
     )
     return thing(*args, **kwargs)
コード例 #4
0
    def test_it_errors_when_not_seeing_an_expected_deprecation(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(kind=emitted.Callable(object=deprecated)):
                pass