コード例 #1
0
    def test_add_boilerplate_to_file(self):
        with tmp_copy("./testdata/default/fail.sh", suffix='.sh') as tmp_file_name:
            boilerplate.ensure_boilerplate_file(
                tmp_file_name, boilerplate.get_refs(), boilerplate.get_regexs(), []
            )

            passes = boilerplate.file_passes(
                tmp_file_name, boilerplate.get_refs(), boilerplate.get_regexs(), [])
            self.assertEqual(passes, True)

            with open(tmp_file_name) as x:
                first_line = x.read().splitlines()[0]
                self.assertEqual(first_line, '#!/usr/bin/env bash')
コード例 #2
0
    def test_replace_specials(self):
        extension = "sh"
        regexs = boilerplate.get_regexs()

        original_content = "\n".join([
            "#!/usr/bin/env bash",
            "",
            "something something",
            "#!/usr/bin/env bash",
        ])
        expected_content = "\n".join([
            "something something",
            "#!/usr/bin/env bash",
        ])
        expected_match = "\n".join([
            "#!/usr/bin/env bash",
            "\n",
        ])

        actual_content, actual_match = boilerplate.replace_specials(
            original_content, extension, regexs
        )

        self.assertEquals(actual_content, expected_content)
        self.assertEquals(actual_match, expected_match)
コード例 #3
0
    def test_get_files_with_skipping_not_generated_files(self):
        refs = boilerplate.get_refs()
        regexes = boilerplate.get_regexs()
        files_to_skip = ['boilerplate.py']
        filename = 'boilerplate.py'

        passes = boilerplate.file_passes(filename, refs, regexes,
                                         files_to_skip)

        self.assertEqual(passes, True)
コード例 #4
0
 def test_ignore_when_no_valid_boilerplate_template(self):
     with tempfile.NamedTemporaryFile() as temp_file_to_check:
         passes = boilerplate.file_passes(temp_file_to_check.name,
                                          boilerplate.get_refs(),
                                          boilerplate.get_regexs(), [])
         self.assertEqual(passes, True)