mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
committed by
GitHub
parent
954fdd5e8f
commit
a2218988ee
@@ -73,6 +73,9 @@ class CommandLineTestCase(unittest.TestCase):
|
||||
# file in dir
|
||||
'sub/ok.yaml': '---\n'
|
||||
'key: value\n',
|
||||
# directory that looks like a yaml file
|
||||
'sub/directory.yaml/not-yaml.txt': '',
|
||||
'sub/directory.yaml/empty.yml': '',
|
||||
# file in very nested dir
|
||||
's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml': '---\n'
|
||||
'key: value\n'
|
||||
@@ -108,6 +111,7 @@ class CommandLineTestCase(unittest.TestCase):
|
||||
os.path.join(self.wd, 'dos.yml'),
|
||||
os.path.join(self.wd, 'empty.yml'),
|
||||
os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml'),
|
||||
os.path.join(self.wd, 'sub/directory.yaml/empty.yml'),
|
||||
os.path.join(self.wd, 'sub/ok.yaml'),
|
||||
os.path.join(self.wd, 'warn.yaml')],
|
||||
)
|
||||
@@ -132,6 +136,7 @@ class CommandLineTestCase(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
sorted(cli.find_files_recursively(items, conf)),
|
||||
[os.path.join(self.wd, '/etc/another/file'),
|
||||
os.path.join(self.wd, 'sub/directory.yaml/empty.yml'),
|
||||
os.path.join(self.wd, 'sub/ok.yaml')],
|
||||
)
|
||||
|
||||
@@ -152,7 +157,8 @@ class CommandLineTestCase(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
sorted(cli.find_files_recursively([self.wd], conf)),
|
||||
[os.path.join(self.wd, 'dos.yml'),
|
||||
os.path.join(self.wd, 'empty.yml')]
|
||||
os.path.join(self.wd, 'empty.yml'),
|
||||
os.path.join(self.wd, 'sub/directory.yaml/empty.yml')]
|
||||
)
|
||||
|
||||
conf = config.YamlLintConfig('extends: default\n'
|
||||
@@ -174,6 +180,8 @@ class CommandLineTestCase(unittest.TestCase):
|
||||
os.path.join(self.wd, 'no-yaml.json'),
|
||||
os.path.join(self.wd, 'non-ascii/éçäγλνπ¥/utf-8'),
|
||||
os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml'),
|
||||
os.path.join(self.wd, 'sub/directory.yaml/empty.yml'),
|
||||
os.path.join(self.wd, 'sub/directory.yaml/not-yaml.txt'),
|
||||
os.path.join(self.wd, 'sub/ok.yaml'),
|
||||
os.path.join(self.wd, 'warn.yaml')]
|
||||
)
|
||||
@@ -191,6 +199,8 @@ class CommandLineTestCase(unittest.TestCase):
|
||||
os.path.join(self.wd, 'no-yaml.json'),
|
||||
os.path.join(self.wd, 'non-ascii/éçäγλνπ¥/utf-8'),
|
||||
os.path.join(self.wd, 's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml'),
|
||||
os.path.join(self.wd, 'sub/directory.yaml/empty.yml'),
|
||||
os.path.join(self.wd, 'sub/directory.yaml/not-yaml.txt'),
|
||||
os.path.join(self.wd, 'sub/ok.yaml'),
|
||||
os.path.join(self.wd, 'warn.yaml')]
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ class YamlLintConfig(object):
|
||||
return self.ignore and self.ignore.match_file(filepath)
|
||||
|
||||
def is_yaml_file(self, filepath):
|
||||
return self.yaml_files.match_file(filepath)
|
||||
return self.yaml_files.match_file(os.path.basename(filepath))
|
||||
|
||||
def enabled_rules(self, filepath):
|
||||
return [yamllint.rules.get(id) for id, val in self.rules.items()
|
||||
|
||||
Reference in New Issue
Block a user