1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# TODO : Consider reducing the inputs for test functinos
"""The main module that tests different uses of the code-include directive."""
import os
import textwrap
import typing
import unittest
from unittest import mock
import bs4
from docutils import nodes as nodes_
from code_include import error_classes
from code_include import extension
from .. import common
_CURRENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
class Inputs(unittest.TestCase):
"""Check that different input to the code-include directive works as-expected."""
@mock.patch("code_include.extension.Directive._reraise_exception")
@mock.patch("code_include.source_code._get_source_code_from_object")
@mock.patch("code_include.source_code._get_app_inventory")
def _test(
self,
content: list[str],
exception_class: typing.Type[Exception],
_get_app_inventory: mock.MagicMock,
_get_source_code_from_object: mock.MagicMock,
_reraise_exception: mock.MagicMock,
) -> None:
"""A generic function that checks a code-include directive for issues.
Args:
content:
The lines that the user provides in a standard code-include block.
exception_class:
The exception that should be raised, when given `content`.
_get_app_inventory:
The function that's normally used to query a Sphinx
project's inventory to find every HTML file-path and
tag-able header.
_reraise_exception:
A function that must be set to return `True` so that
this test will forcibly raise the found exception.
"""
data = common.load_cache(
os.path.join(_CURRENT_DIRECTORY, "fake_project", "objects.inv")
)
_get_app_inventory.return_value = data
_reraise_exception.return_value = True
_get_source_code_from_object.return_value = ""
directive = common.make_mock_directive(content)
with self.assertRaises(exception_class):
directive.run()
def test_no_required_argument(self) -> None:
"""Check that missing content raises the expected exception."""
self._test( # pylint: disable=no-value-for-parameter
[""], error_classes.MissingContent
)
def test_incorrect_directive_target(self) -> None:
"""Check that a bad tag like ":foo:" raises the expected exception."""
self._test( # pylint: disable=no-value-for-parameter
[":nonexistent:tag:`some.module.that.may.exist`"],
error_classes.MissingTag,
)
def test_incorrect_namespace(self) -> None:
"""Fail to generate text because the tag's namespace is missing."""
self._test( # pylint: disable=no-value-for-parameter
[":meth:`path.that.does.not.exist`"], error_classes.MissingNamespace
)
class ContentsStore(unittest.TestCase):
"""A class that provides input text for other unittest classes.
The text in this class mimics what the user would write in a regular
code-include block.
"""
@staticmethod
def _get_fake_project_class() -> list[str]:
return [":class:`fake_project.basic.MyKlass`"]
@staticmethod
def _get_fake_project_function() -> list[str]:
return [":func:`fake_project.basic.set_function_thing`"]
@staticmethod
def _get_fake_project_module() -> list[str]:
return [":mod:`fake_project.basic`"]
@staticmethod
def _get_fake_project_nested_class() -> list[str]:
return [":class:`fake_project.nested_folder.another.MyKlass`"]
@staticmethod
def _get_fake_project_nested_function() -> list[str]:
return [":func:`fake_project.nested_folder.another.set_function_thing`"]
@staticmethod
def _get_fake_project_nested_private_function() -> list[str]:
return [
":func:`fake_project.nested_folder.another._set_private_function_thing`"
]
@staticmethod
def _get_fake_project_nested_method() -> list[str]:
return [":meth:`fake_project.nested_folder.another.MyKlass.get_method`"]
@staticmethod
def _get_fake_project_nested_module() -> list[str]:
return [":mod:`fake_project.nested_folder.another`"]
@staticmethod
def _get_fake_project_private_function() -> list[str]:
return [":func:`fake_project.basic._set_private_function_thing`"]
@staticmethod
def _get_fake_project_method() -> list[str]:
return [":meth:`fake_project.basic.MyKlass.get_method`"]
class Linking(ContentsStore):
"""A class that checks if linking to source code and documentation works."""
@staticmethod
@mock.patch("code_include.source_code._get_source_module_data")
@mock.patch("code_include.source_code._get_source_code_from_object")
@mock.patch("code_include.source_code._get_app_inventory")
def _get_nodes(
data: str,
content: list[str],
_inventory: mock.MagicMock,
_get_from_object: mock.MagicMock,
_get_source_module_data: mock.MagicMock,
) -> list[nodes_.literal_block]:
cache = common.load_cache(
os.path.join(_CURRENT_DIRECTORY, "fake_project", "objects.inv")
)
_inventory.return_value = cache
_get_source_module_data.return_value = data
_get_from_object.return_value = ""
directive = common.make_mock_directive(content)
return directive.run()
@mock.patch("code_include.source_code._get_source_code_from_object")
@mock.patch("code_include.extension.Directive._is_link_requested")
@mock.patch("code_include.extension.Directive._needs_unindent")
def test_link_to_documentation(
self,
_needs_unindent: mock.MagicMock,
_is_link_requested: mock.MagicMock,
_get_source_code_from_object: mock.MagicMock,
) -> None:
"""Link to the original page where Python source-code was found.
Args:
_needs_unindent:
The patched function that controls indentation of code-include.
_is_link_requested:
This adds a hyperlink to the original Python documentation.
_get_source_code_from_object:
Disable reading from source-code. This forces
sphinx-code-include to read from a Sphinx inventory
file.
"""
_needs_unindent.return_value = False
_is_link_requested.return_value = True
_get_source_code_from_object.return_value = ""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"MyKlass.get_method",
)
content = self._get_fake_project_method()
nodes = self._get_nodes(data, content) # pylint: disable=no-value-for-parameter
self.assertEqual(2, len(nodes))
self.assertTrue(
any(
node
for node in nodes
if isinstance(
node,
extension._DocumentationHyperlink, # pylint: disable=protected-access
)
)
)
@mock.patch("code_include.source_code._get_source_code_from_object")
@mock.patch("code_include.extension.Directive._is_source_requested")
@mock.patch("code_include.extension.Directive._needs_unindent")
def test_link_to_source(
self,
_needs_unindent: mock.MagicMock,
_is_source_requested: mock.MagicMock,
_get_source_code_from_object: mock.MagicMock,
) -> None:
"""Link to the original page where Python source-code was found.
Args:
_needs_unindent:
The patched function that controls indentation of code-include.
_is_source_requested:
This adds a hyperlink to the original Python source-code.
_get_source_code_from_object:
Disable reading from source-code. This forces
sphinx-code-include to read from a Sphinx inventory
file.
"""
_needs_unindent.return_value = False
_is_source_requested.return_value = True
_get_source_code_from_object.return_value = ""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"MyKlass.get_method",
)
content = self._get_fake_project_method()
nodes = self._get_nodes(data, content) # pylint: disable=no-value-for-parameter
self.assertEqual(2, len(nodes))
self.assertTrue(
any(
node
for node in nodes
if isinstance(
node,
extension._SourceCodeHyperlink, # pylint: disable=protected-access
)
)
)
class _Common(ContentsStore):
"""A base class which is used by sub-classes to make tests more concise."""
@mock.patch("code_include.source_code._get_source_module_data")
@mock.patch("code_include.source_code._get_source_code_from_object")
@mock.patch("code_include.source_code._get_app_inventory")
def _test(
self,
data: tuple[str, str],
content: list[str],
expected: str,
_inventory: mock.MagicMock,
_get_from_object: mock.MagicMock,
_get_source_module_data: mock.MagicMock,
) -> None:
"""A generic function that tests a code-include directive for some text.
Args:
data:
The absolute path to an HTML file and the "#foo" tag that
would normally be used as a permalink to some header in the
HTML file.
content:
The lines that the user provides in a standard code-include block.
expected:
The converted source-code text that will be tested for.
_inventory:
The function that's normally used to query a Sphinx
project's inventory to find every HTML file-path and
tag-able header.
_get_source_module_data:
A function that is mocked so that we can skip some of
the less important tag-parsing functions and get to the
point of this function - testing generated source-code.
"""
cache = common.load_cache(
os.path.join(_CURRENT_DIRECTORY, "fake_project", "objects.inv")
)
_inventory.return_value = cache
_get_source_module_data.return_value = data
_get_from_object.return_value = ""
directive = common.make_mock_directive(content)
nodes = directive.run()
found = str(nodes[0].astext())
self.assertEqual(1, len(nodes))
self.assertEqual(expected.split("\n"), found.split("\n"))
class RenderText(_Common):
"""A class that checks to make sure projects get and return the right code."""
def test_get_from_html(self) -> None:
"""Check that a basic HTML file can be read."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"MyKlass.get_method",
)
content = self._get_fake_project_method()
expected = textwrap.dedent(
'''\
def get_method(self):
"""int: Get some value."""
return 8'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_class(self) -> None:
"""Check that a class is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"MyKlass",
)
content = self._get_fake_project_class()
expected = textwrap.dedent(
'''\
class MyKlass(object):
"""A class that does something.
Multi-line information here.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "asdfasdf"
def __init__(self, value):
"""Create this instance."""
# A comment that should show up in the unittest's results
super(MyKlass, self).__init__()
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 8
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 8
def get_method(self):
"""int: Get some value."""
return 8'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_function(self) -> None:
"""Check that a module's function is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"set_function_thing",
)
content = self._get_fake_project_function()
expected = textwrap.dedent(
"""\
def set_function_thing(value, another):
if value:
return 2
return 1"""
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_private_function(self) -> None:
"""Check that a module's function is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"_set_private_function_thing",
)
content = self._get_fake_project_private_function()
expected = textwrap.dedent(
'''\
def _set_private_function_thing(value, another):
"""Do something here."""
# Do something with these values
# and more comment text, here.
#
if value:
return 2
# Another comment
return 1'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_module(self) -> None:
"""Check that a module is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"",
)
content = self._get_fake_project_module()
expected = textwrap.dedent(
'''\
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""A module that shows every type of documentable class / method / function.
Attributes:
ATTRIBUTE_VALUE (float):
Some number.
"""
ATTRIBUTE_VALUE = 14.3
class MyKlass(object):
"""A class that does something.
Multi-line information here.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "asdfasdf"
def __init__(self, value):
"""Create this instance."""
# A comment that should show up in the unittest's results
super(MyKlass, self).__init__()
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 8
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 8
def get_method(self):
"""int: Get some value."""
return 8
class ParentClass(object):
"""The outter class.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "tttt"
class NestedClass(object):
"""A class within a class.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "zzzzzzzzzzzzz"
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 5
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 5
def get_method(self):
"""int: Get some value."""
return 5
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 6
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 6
def get_method(self):
"""int: Get some value."""
return 6
def _set_private_function_thing(value, another):
"""Do something here."""
# Do something with these values
# and more comment text, here.
#
if value:
return 2
# Another comment
return 1
def set_function_thing(value, another):
if value:
return 2
return 1'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
class RenderTextNested(_Common):
"""A class that checks to make sure projects get and return the right code."""
def test_get_from_html(self) -> None:
"""Check that a basic HTML file can be read."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"nested_folder",
"another.html",
),
"MyKlass.get_method",
)
content = self._get_fake_project_nested_method()
expected = textwrap.dedent(
'''\
def get_method(self):
"""int: Get some value."""
return 8'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_class(self) -> None:
"""Check that a class is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"nested_folder",
"another.html",
),
"MyKlass",
)
content = self._get_fake_project_nested_class()
expected = textwrap.dedent(
'''\
class MyKlass(object):
"""A class that does something.
Multi-line information here.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "asdfasdf"
def __init__(self, value):
"""Create this instance."""
# A comment that should show up in the unittest's results
super(MyKlass, self).__init__()
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 8
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 8
def get_method(self):
"""int: Get some value."""
return 8'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_function(self) -> None:
"""Check that a module's function is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"nested_folder",
"another.html",
),
"set_function_thing",
)
content = self._get_fake_project_nested_function()
expected = textwrap.dedent(
"""\
def set_function_thing(value, another):
if value:
return 2
return 1"""
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_private_function(self) -> None:
"""Check that a module's function is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"nested_folder",
"another.html",
),
"_set_private_function_thing",
)
content = self._get_fake_project_nested_private_function()
expected = textwrap.dedent(
'''\
def _set_private_function_thing(value, another):
"""Do something here."""
# Do something with these values
# and more comment text, here.
#
if value:
return 2
# Another comment
return 1'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
def test_module(self) -> None:
"""Check that a module is read properly."""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"nested_folder",
"another.html",
),
"",
)
content = self._get_fake_project_nested_module()
expected = textwrap.dedent(
'''\
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""A module that shows every type of documentable class / method / function.
Attributes:
ATTRIBUTE_VALUE (float):
Some number.
"""
ATTRIBUTE_VALUE = 14.3
class MyKlass(object):
"""A class that does something.
Multi-line information here.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "asdfasdf"
def __init__(self, value):
"""Create this instance."""
# A comment that should show up in the unittest's results
super(MyKlass, self).__init__()
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 8
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 8
def get_method(self):
"""int: Get some value."""
return 8
class ParentClass(object):
"""The outter class.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "tttt"
class NestedClass(object):
"""A class within a class.
Attributes:
attribute_value (str):
Some string.
"""
attribute_value = "zzzzzzzzzzzzz"
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 5
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 5
def get_method(self):
"""int: Get some value."""
return 5
@staticmethod
def get_staticmethod():
"""int: Get some value."""
return 6
@classmethod
def get_classmethod(cls):
"""int: Get some value."""
return 6
def get_method(self):
"""int: Get some value."""
return 6
def _set_private_function_thing(value, another):
"""Do something here."""
# Do something with these values
# and more comment text, here.
#
if value:
return 2
# Another comment
return 1
def set_function_thing(value, another):
if value:
return 2
return 1'''
)
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
class Options(_Common):
"""Make sure code-include directive options work for :obj: tags."""
@mock.patch("code_include.source_code._get_app_inventory")
def test_fallback_text_missing(
self,
_get_app_inventory: mock.MagicMock,
) -> None:
"""Raise an exception if the namespace is missing and no fallback is given."""
_get_app_inventory.return_value = {"fake": {"thing": ["stuff"]}}
content = [":meth:`path.that.does.not.exist`"]
directive = common.make_mock_directive(content, options={"fallback-text": ""})
self.assertFalse(directive.run())
@mock.patch("code_include.source_code._get_app_inventory")
def test_fallback_text_simple(
self,
_get_app_inventory: mock.MagicMock,
) -> None:
"""Show fallback text if the namespace is missing and fallback text is given."""
fallback = "Some fallback text"
_get_app_inventory.return_value = {}
content = [":meth:`path.that.does.not.exist`"]
directive = common.make_mock_directive(
content,
options={"fallback-text": fallback},
)
results = directive.run()
self.assertEqual(1, len(results))
literal_block = results[0]
self.assertEqual(fallback, literal_block.astext())
@mock.patch("code_include.source_code._get_source_code_from_object")
@mock.patch("code_include.extension.Directive._needs_unindent")
def test_no_unindent(
self,
_needs_unindent: mock.MagicMock,
_get_source_code_from_object: mock.MagicMock,
) -> None:
"""Check that code-include doesn't remove leading whitespace, when selected.
Args:
_needs_unindent:
The patched function that controls indentation of code-include.
"""
_needs_unindent.return_value = False
_get_source_code_from_object.return_value = ""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"MyKlass.get_method",
)
content = self._get_fake_project_method()
expected = '''\
def get_method(self):
"""int: Get some value."""
return 8'''
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
@mock.patch("code_include.source_code._get_source_code_from_object")
@mock.patch("code_include.source_code._get_page_preprocessor")
def test_preprocessor(
self,
_get_page_preprocessor: mock.MagicMock,
_get_source_code_from_object: mock.MagicMock,
) -> None:
"""Check that the optional user-configuration function works correctly."""
def _remove_comments_and_docstrings(node: bs4.BeautifulSoup) -> None:
for tag in node.find_all("span", {"class": ["c1", "sd"]}):
tag.decompose()
_get_page_preprocessor.return_value = _remove_comments_and_docstrings
_get_source_code_from_object.return_value = ""
data = (
os.path.join(
_CURRENT_DIRECTORY,
"fake_project",
"_modules",
"fake_project",
"basic.html",
),
"set_function_thing",
)
content = self._get_fake_project_function()
expected = """\
def set_function_thing(value, another):
if value:
return 2
return 1"""
self._test(data, content, expected) # pylint: disable=no-value-for-parameter
|