| Total Complexity | 7 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from lagom import Container, bind_to_container, magic_bind_to_container |
||
| 4 | from lagom.exceptions import ClassesCannotBeDecorated |
||
| 5 | |||
| 6 | container = Container() |
||
| 7 | |||
| 8 | |||
| 9 | @bind_to_container(container) |
||
| 10 | def _do_something(): |
||
| 11 | """ |
||
| 12 | The doc string |
||
| 13 | :return: |
||
| 14 | """ |
||
| 15 | pass |
||
| 16 | |||
| 17 | |||
| 18 | @magic_bind_to_container(container) |
||
| 19 | def _do_something_magic(): |
||
| 20 | """ |
||
| 21 | The magic doc string |
||
| 22 | :return: |
||
| 23 | """ |
||
| 24 | pass |
||
| 25 | |||
| 26 | |||
| 27 | def test_doc_strings_are_preserved(): |
||
| 28 | assert _do_something.__doc__ |
||
| 29 | assert _do_something_magic.__doc__ |
||
| 30 | assert "The doc string" in _do_something.__doc__ |
||
| 31 | assert "The magic doc string" in _do_something_magic.__doc__ |
||
| 32 | |||
| 33 | |||
| 34 | def test_classes_can_not_be_decorated(): |
||
| 35 | with pytest.raises(ClassesCannotBeDecorated): |
||
| 36 | |||
| 37 | @bind_to_container(container) |
||
| 38 | class TestThisThing: |
||
| 39 | pass |
||
| 40 | |||
| 41 | |||
| 42 | def test_classes_can_not_be_magic_decorated(): |
||
| 43 | with pytest.raises(ClassesCannotBeDecorated): |
||
| 44 | |||
| 45 | @magic_bind_to_container(container) |
||
| 46 | class TestThisOtherThing: |
||
| 47 | pass |
||
| 48 |