Пример #1
0
    def test_dot(self):
        """A single dot path (e.g. ".") should return the current directory."""
        description = message_description.Description(
            [],
            message_description.Location(".", 0, 0, ""),
            base_checker.Code(short_name="Z", long_name="some-code"),
        )

        self.assertEqual(os.getcwd(), description.get_header())
Пример #2
0
    def test_summary(self):
        """Make sure description summarizes print as-expected."""
        description = message_description.Description(
            ["Some important message"],
            message_description.Location(".", 0, 0, ""),
            base_checker.Code(short_name="Z", long_name="some-code"),
        )

        self.assertEqual(["Z: 0, 0: Some important message (some-code)"],
                         description.get_message())
Пример #3
0
    def test_absolute(self):
        """A location that is next to or above the current directory should return absolute."""
        parent = os.path.dirname(os.getcwd())

        description = message_description.Description(
            [],
            message_description.Location(parent, 0, 0, ""),
            base_checker.Code(short_name="Z", long_name="some-code"),
        )

        self.assertEqual(parent, description.get_header())
Пример #4
0
    def test_relative_001(self):
        """A location that is below the current directory should return relative."""
        description = message_description.Description(
            [],
            message_description.Location(
                os.path.join(os.getcwd(), "something", "else"), 0, 0, ""),
            base_checker.Code(short_name="Z", long_name="some-code"),
        )

        self.assertEqual(os.path.join("something", "else"),
                         description.get_header())
    def _get_no_documentation_message(directory):
        summary = "No documentation found"

        return message_description.Description(
            [summary],
            message_description.Location(directory, 0, 0, ""),
            base_checker.Code(short_name="E", long_name="no-documentation"),
            full=[
                summary,
                "Consider adding documentation to your Python package.",
                "Reference: https://www.sphinx-doc.org/en/master/usage/quickstart.html",
            ],
        )
Пример #6
0
    def test_sorting(self):
        """Make sure the vimgrep output is sorted correctly."""
        descriptions = [
            message_description.Description(
                ["some text"],
                message_description.Location("foo", 110, 3, ""),
                base_checker.Code(short_name="Z", long_name="some-code"),
            ),
            message_description.Description(
                ["bar"],
                message_description.Location("foo", 1, 10, ""),
                base_checker.Code(short_name="Z", long_name="some-code"),
            ),
            message_description.Description(
                ["another"],
                message_description.Location("foo", 1, 10, ""),
                base_checker.Code(short_name="Z", long_name="some-code"),
            ),
            message_description.Description(
                ["foo"],
                message_description.Location("foo", 20, 10, ""),
                base_checker.Code(short_name="Z", long_name="some-code"),
            ),
        ]

        lines = []
        lines.extend(line for description in descriptions
                     for line in description.get_message(verbose=True))

        self.assertEqual(
            [
                "Z: 1, 10: another (some-code)",
                "Z: 1, 10: bar (some-code)",
                "Z: 20, 10: foo (some-code)",
                "Z: 110, 3: some text (some-code)",
            ],
            message_description.sort_with_vimgrep(lines),
        )
Пример #7
0
    def test_full(self):
        """Make sure description summarizes print as-expected."""
        summary = "Some important message"
        description = message_description.Description(
            [summary],
            message_description.Location(".", 0, 0, ""),
            base_checker.Code(short_name="Z", long_name="some-code"),
            full=[summary, "More information here", "And even more"],
        )

        self.assertEqual(
            [
                "Z: 0, 0: Some important message (some-code)",
                "    More information here",
                "    And even more",
            ],
            description.get_message(verbose=True),
        )
Пример #8
0
    def test_vimgrep_002(self):
        """Check that Description prints path / row / column information correctly."""
        root = tempfile.mkdtemp()
        self.delete_item_later(root)

        description = message_description.Description(
            ["some text"],
            message_description.Location(root, 110, 3, ""),
            base_checker.Code(short_name="Z", long_name="some-code"),
        )

        self.assertEqual(["Z: 110, 3: some text (some-code)"],
                         description.get_message(verbose=True))
        self.assertEqual(0, description.get_padding_row())
        self.assertEqual(1, description.get_padding_column())
        self.assertEqual(
            "{root}:110:3: (some-code)".format(root=root),
            description.get_location_data(),
        )
 def _get_no_readme_message(directory):
     return message_description.Description(
         ["Rez package has no README file"],
         message_description.Location(directory, 0, 0, ""),
         base_checker.Code(short_name="E", long_name="no-read-me"),
     )
 def _get_no_changelog_message(directory):
     return message_description.Description(
         ["Rez package has no CHANGELOG file"],
         message_description.Location(directory, 0, 0, ""),
         base_checker.Code(short_name="E", long_name="no-change-log"),
     )