def test_match_absolute_dir(self):
        fp, path = tempfile.mkstemp(text=True)
        os.write(fp, "# -*- coding: utf-8 -*-\n".encode("ascii"))
        os.close(fp)

        errors = check_pep257(path, match_dir="[^\.].*")
        assert_that(errors, has_length(1))

        os.unlink(path)
    def test_match_absolute_dir(self):
        fp, path = tempfile.mkstemp(text=True)
        os.write(fp, "# -*- coding: utf-8 -*-\n".encode("ascii"))
        os.close(fp)

        errors = check_pep257(path, match_dir="[^\.].*")
        assert_that(errors, has_length(1))

        os.unlink(path)
 def test_match_dir(self):
     """test only the directories that are matched by the regex"""
     errors = check_pep257("foo/.hidden/spam/eggs/bar.py",
                           match_dir="[^\.].*")
     assert_that(errors, has_length(0))
 def test_match(self):
     """test only the file that are matched by the regex"""
     errors = check_pep257("test_bar.py", match="(?!test_).*\.py")
     assert_that(errors, has_length(0))
 def test_ignore(self):
     """ignored PEP257 codes are ignored"""
     errors = check_pep257(self.invalid, ignore=('D100'))
     assert_that(errors, has_length(0))
 def test_invalid_all(self):
     """invalid_all.py has a mutable all"""
     errors = check_pep257(self.invalid_all)
     assert_that(errors, has_length(1))
     assert_that(errors[0], contains_string("Could not evaluate contents of"
                                            " __all__. That means pep257"))
 def test_invalid_token(self):
     """invalid_token.py has a tokenization error"""
     errors = check_pep257(self.invalid_token)
     assert_that(errors, has_item("6:0 EOF in multi-line string"))
 def test_invalid_token(self):
     """invalid_token.py has a tokenization error"""
     errors = check_pep257(self.invalid_token)
     assert_that(errors, has_item("6:0 EOF in multi-line string"))
 def test_invalid_whitespaces(self):
     """invalid_whitespaces.py is incorrectly formatted."""
     errors = check_pep257(self.invalid_whitespaces)
     assert_that(errors, has_length(5))
 def test_valid(self):
     """valid.py is correctly formatted (according to pep257)"""
     errors = check_pep257(self.valid)
     assert_that(errors, has_length(0))
 def test_match_dir(self):
     """test only the directories that are matched by the regex"""
     errors = check_pep257("foo/.hidden/spam/eggs/bar.py", match_dir="[^\.].*")
     assert_that(errors, has_length(0))
 def test_match(self):
     """test only the file that are matched by the regex"""
     errors = check_pep257("test_bar.py", match="(?!test_).*\.py")
     assert_that(errors, has_length(0))
 def test_ignore(self):
     """ignored PEP257 codes are ignored"""
     errors = check_pep257(self.invalid, ignore=("D100"))
     assert_that(errors, has_length(0))
 def test_invalid_all(self):
     """invalid_all.py has a mutable all"""
     errors = check_pep257(self.invalid_all)
     assert_that(errors, has_length(1))
     assert_that(errors[0], contains_string("Could not evaluate contents of" " __all__. That means pep257"))
 def test_valid(self):
     """valid.py is correctly formatted (according to pep257)"""
     errors = check_pep257(self.valid)
     assert_that(errors, has_length(0))
 def test_missing(self):
     """invalid.py has no docstring"""
     errors = check_pep257(self.invalid)
     assert_that(errors, has_item("1: D100 Missing docstring in public module"))
 def test_invalid_whitespaces(self):
     """invalid_whitespaces.py is incorrectly formatted."""
     errors = check_pep257(self.invalid_whitespaces)
     assert_that(errors, has_length(5))
 def test_missing(self):
     """invalid.py has no docstring"""
     errors = check_pep257(self.invalid)
     assert_that(errors, has_item("1: D100 Missing docstring in public module"))