当前位置: 首页>>代码示例>>Python>>正文


Python Phpcs.check_dependencies方法代码示例

本文整理汇总了Python中lintreview.tools.phpcs.Phpcs.check_dependencies方法的典型用法代码示例。如果您正苦于以下问题:Python Phpcs.check_dependencies方法的具体用法?Python Phpcs.check_dependencies怎么用?Python Phpcs.check_dependencies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lintreview.tools.phpcs.Phpcs的用法示例。


在下文中一共展示了Phpcs.check_dependencies方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Testphpcs

# 需要导入模块: from lintreview.tools.phpcs import Phpcs [as 别名]
# 或者: from lintreview.tools.phpcs.Phpcs import check_dependencies [as 别名]
class Testphpcs(TestCase):

    needs_phpcs = skipIf(phpcs_missing, 'Needs phpcs')

    fixtures = [
        'tests/fixtures/phpcs/no_errors.php',
        'tests/fixtures/phpcs/has_errors.php',
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Phpcs(self.problems)

    def test_match_file(self):
        self.assertTrue(self.tool.match_file('test.php'))
        self.assertTrue(self.tool.match_file('dir/name/test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertFalse(self.tool.match_file('test.js'))

    @needs_phpcs
    def test_check_dependencies(self):
        self.assertTrue(self.tool.check_dependencies())

    @needs_phpcs
    def test_process_files__one_file_pass(self):
        self.tool.process_files([self.fixtures[0]])
        eq_([], self.problems.all(self.fixtures[0]))

    @needs_phpcs
    def test_process_files__one_file_fail(self):
        self.tool.process_files([self.fixtures[1]])
        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

        fname = self.fixtures[1]
        expected = Comment(
            fname,
            14,
            14,
            'Opening brace should be on a new line')
        eq_(expected, problems[0])

        expected = Comment(
            fname,
            16,
            16,
            "Spaces must be used to indent lines; tabs are not allowed")
        eq_(expected, problems[2])

    @needs_phpcs
    def test_process_files_two_files(self):
        self.tool.process_files(self.fixtures)

        eq_([], self.problems.all(self.fixtures[0]))

        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

    @needs_phpcs
    def test_process_files_with_config(self):
        config = {
            'standard': 'Zend'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(3, len(problems), 'Changing standards changes error counts')

    def test_create_command__with_path_based_standard(self):
        command = 'vendor/bin/phpcs'
        if phpcs_missing:
            command = 'phpcs'
        config = {
            'standard': 'test/CodeStandards',
            'tab_width': 4,
        }
        tool = Phpcs(self.problems, config, '/some/path')
        result = tool.create_command(['some/file.php'])
        expected = [
            command,
            '--report=checkstyle',
            '--standard=/some/path/test/CodeStandards',
            '--extensions=php',
            '--tab-width=4',
            'some/file.php'
        ]
        eq_(result, expected)
开发者ID:halfcrazy,项目名称:lint-review,代码行数:92,代码来源:test_phpcs.py

示例2: Testphpcs

# 需要导入模块: from lintreview.tools.phpcs import Phpcs [as 别名]
# 或者: from lintreview.tools.phpcs.Phpcs import check_dependencies [as 别名]
class Testphpcs(TestCase):

    needs_phpcs = skipIf(phpcs_missing, 'Needs phpcs')

    fixtures = [
        'tests/fixtures/phpcs/no_errors.php',
        'tests/fixtures/phpcs/has_errors.php',
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Phpcs(self.problems)

    def test_match_file(self):
        self.assertTrue(self.tool.match_file('test.php'))
        self.assertTrue(self.tool.match_file('dir/name/test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertFalse(self.tool.match_file('test.js'))

    @needs_phpcs
    def test_check_dependencies(self):
        self.assertTrue(self.tool.check_dependencies())

    @needs_phpcs
    def test_process_files__one_file_pass(self):
        self.tool.process_files([self.fixtures[0]])
        eq_([], self.problems.all(self.fixtures[0]))

    @needs_phpcs
    def test_process_files__one_file_fail(self):
        self.tool.process_files([self.fixtures[1]])
        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

        fname = self.fixtures[1]
        expected = Comment(
            fname,
            14,
            14,
            'Opening brace should be on a new line')
        eq_(expected, problems[0])

        expected = Comment(
            fname,
            16,
            16,
            "Spaces must be used to indent lines; tabs are not allowed")
        eq_(expected, problems[2])

    @needs_phpcs
    def test_process_files_two_files(self):
        self.tool.process_files(self.fixtures)

        eq_([], self.problems.all(self.fixtures[0]))

        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

    @needs_phpcs
    def test_process_files__with_config(self):
        config = {
            'standard': 'Zend'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(3, len(problems), 'Changing standards changes error counts')

    @needs_phpcs
    def test_process_files__with_ignore(self):
        config = {
            'standard': 'PSR2',
            'ignore': 'tests/fixtures/phpcs/*'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(0, len(problems), 'ignore option should exclude files')

    @needs_phpcs
    def test_process_files__with_exclude(self):
        config = {
            'standard': 'PSR2',
            'exclude': 'Generic.WhiteSpace.DisallowTabIndent'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(1, len(problems), 'exclude option should reduce errors.')

    @needs_phpcs
    def test_process_files__with_invalid_exclude(self):
        config = {
#.........这里部分代码省略.........
开发者ID:esoergel,项目名称:lint-review,代码行数:103,代码来源:test_phpcs.py

示例3: Testphpcs

# 需要导入模块: from lintreview.tools.phpcs import Phpcs [as 别名]
# 或者: from lintreview.tools.phpcs.Phpcs import check_dependencies [as 别名]
class Testphpcs(TestCase):

    needs_phpcs = skipIf(phpcs_missing, 'Needs phpcs')

    fixtures = [
        'tests/fixtures/phpcs/no_errors.php',
        'tests/fixtures/phpcs/has_errors.php',
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Phpcs(self.problems)

    def test_match_file(self):
        self.assertTrue(self.tool.match_file('test.php'))
        self.assertTrue(self.tool.match_file('dir/name/test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertFalse(self.tool.match_file('test.js'))

    @needs_phpcs
    def test_check_dependencies(self):
        self.assertTrue(self.tool.check_dependencies())

    @needs_phpcs
    def test_process_files__one_file_pass(self):
        self.tool.process_files([self.fixtures[0]])
        eq_([], self.problems.all(self.fixtures[0]))

    @needs_phpcs
    def test_process_files__one_file_fail(self):
        self.tool.process_files([self.fixtures[1]])
        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

        fname = self.fixtures[1]
        expected = Comment(
            fname,
            14,
            14,
            'Opening brace should be on a new line')
        eq_(expected, problems[0])

        expected = Comment(
            fname,
            16,
            16,
            "Spaces must be used to indent lines; tabs are not allowed")
        eq_(expected, problems[2])

    @needs_phpcs
    def test_process_files_two_files(self):
        self.tool.process_files(self.fixtures)

        eq_([], self.problems.all(self.fixtures[0]))

        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

    @needs_phpcs
    def test_process_files_with_config(self):
        config = {
            'standard': 'Zend'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(3, len(problems), 'Changing standards changes error counts')

    @needs_phpcs
    def test_process_files_with_ignore(self):
        config = {
            'standard': 'PSR2',
            'ignore': 'tests/fixtures/phpcs/*'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(0, len(problems), 'ignore option should exclude files')

    @needs_phpcs
    def test_process_files_with_exclude(self):
        config = {
            'standard': 'PSR2',
            'exclude': 'Generic.WhiteSpace.DisallowTabIndent'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(1, len(problems), 'exclude option should reduce errors.')

    @needs_phpcs
    def test_process_files_with_invalid_exclude(self):
        config = {
#.........这里部分代码省略.........
开发者ID:adrianmoisey,项目名称:lint-review,代码行数:103,代码来源:test_phpcs.py

示例4: Testphpcs

# 需要导入模块: from lintreview.tools.phpcs import Phpcs [as 别名]
# 或者: from lintreview.tools.phpcs.Phpcs import check_dependencies [as 别名]
class Testphpcs(TestCase):

    needs_phpcs = skipIf(phpcs_missing, 'Needs phpcs')

    fixtures = [
        'tests/fixtures/phpcs/no_errors.php',
        'tests/fixtures/phpcs/has_errors.php',
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Phpcs(self.problems)

    def test_match_file(self):
        self.assertTrue(self.tool.match_file('test.php'))
        self.assertTrue(self.tool.match_file('dir/name/test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertFalse(self.tool.match_file('test.js'))

    @needs_phpcs
    def test_check_dependencies(self):
        self.assertTrue(self.tool.check_dependencies())

    @needs_phpcs
    def test_process_files__one_file_pass(self):
        self.tool.process_files([self.fixtures[0]])
        eq_([], self.problems.all(self.fixtures[0]))

    @needs_phpcs
    def test_process_files__one_file_fail(self):
        self.tool.process_files([self.fixtures[1]])
        problems = self.problems.all(self.fixtures[1])
        eq_(12, len(problems))

        fname = self.fixtures[1]
        expected = Comment(fname, 7, 7, 'PHP version not specified')
        eq_(expected, problems[0])

        expected = Comment(
            fname,
            16,
            16,
            "Line indented incorrectly; expected at least 4 spaces, found 1")
        eq_(expected, problems[11])

    @needs_phpcs
    def test_process_files_two_files(self):
        self.tool.process_files(self.fixtures)

        eq_([], self.problems.all(self.fixtures[0]))

        problems = self.problems.all(self.fixtures[1])
        eq_(12, len(problems))

    @needs_phpcs
    def test_process_files_with_config(self):
        config = {
            'standard': 'Zend'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(8, len(problems), 'Changing standards changes error counts')

    def test_create_command__with_path_based_standard(self):
        config = {
            'standard': 'test/CodeStandards'
        }
        tool = Phpcs(self.problems, config, '/some/path')
        result = tool.create_command(['some/file.php'])
        expected = [
            'phpcs',
            '--report=checkstyle',
            '--standard=/some/path/test/CodeStandards',
            '--extensions=php',
            'some/file.php'
        ]
        eq_(result, expected)
开发者ID:alexBaizeau,项目名称:lint-review,代码行数:83,代码来源:test_phpcs.py

示例5: Testphpcs

# 需要导入模块: from lintreview.tools.phpcs import Phpcs [as 别名]
# 或者: from lintreview.tools.phpcs.Phpcs import check_dependencies [as 别名]
class Testphpcs(TestCase):

    fixtures = ["tests/fixtures/phpcs/no_errors.php", "tests/fixtures/phpcs/has_errors.php"]

    def setUp(self):
        self.problems = Problems()
        self.tool = Phpcs(self.problems)

    def test_match_file(self):
        self.assertTrue(self.tool.match_file("test.php"))
        self.assertTrue(self.tool.match_file("dir/name/test.php"))
        self.assertFalse(self.tool.match_file("dir/name/test.py"))
        self.assertFalse(self.tool.match_file("test.py"))
        self.assertFalse(self.tool.match_file("test.js"))

    @skipIf(phpcs_missing, "Missing phpcs, cannot run")
    def test_check_dependencies(self):
        self.assertTrue(self.tool.check_dependencies())

    @skipIf(phpcs_missing, "Missing phpcs, cannot run")
    def test_process_files__one_file_pass(self):
        self.tool.process_files([self.fixtures[0]])
        eq_([], self.problems.all(self.fixtures[0]))

    @skipIf(phpcs_missing, "Missing phpcs, cannot run")
    def test_process_files__one_file_fail(self):
        self.tool.process_files([self.fixtures[1]])
        problems = self.problems.all(self.fixtures[1])
        eq_(12, len(problems))

        fname = self.fixtures[1]
        expected = Comment(fname, 7, 7, "PHP version not specified")
        eq_(expected, problems[0])

        expected = Comment(fname, 16, 16, "Line indented incorrectly; expected at least 4 spaces, found 1")
        eq_(expected, problems[11])

    @skipIf(phpcs_missing, "Missing phpcs, cannot run")
    def test_process_files_two_files(self):
        self.tool.process_files(self.fixtures)

        eq_([], self.problems.all(self.fixtures[0]))

        problems = self.problems.all(self.fixtures[1])
        eq_(12, len(problems))

    @skipIf(phpcs_missing, "Missing phpcs, cannot run")
    def test_process_files_with_config(self):
        config = {"standard": "Zend"}
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(8, len(problems), "Changing standards changes error counts")

    def test_create_command__with_path_based_standard(self):
        config = {"standard": "test/CodeStandards"}
        tool = Phpcs(self.problems, config, "/some/path")
        result = tool.create_command(["some/file.php"])
        expected = [
            "phpcs",
            "--report=checkstyle",
            "--standard=/some/path/test/CodeStandards",
            "--extensions=php",
            "some/file.php",
        ]
        eq_(result, expected)
开发者ID:kevinjqiu,项目名称:lint-review,代码行数:70,代码来源:test_phpcs.py


注:本文中的lintreview.tools.phpcs.Phpcs.check_dependencies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。